ZQuest Classic Coverage Report


Directory: src/
File: src/zq/zquest.cpp
Date: 2024-09-10 05:08:14
Exec Total Coverage
Lines: 2378 15884 15.0%
Functions: 45 751 6.0%
Branches: 1428 11715 12.2%

Line Branch Exec Source
1 #include "base/files.h"
2 #define MIDI_TRACK_BUFFER_SIZE 50
3
4 #include <memory>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <cstring>
8 #include <sstream>
9 #include <ctype.h>
10 #include <assert.h>
11 #include <time.h>
12 #include <vector>
13 #include <filesystem>
14 #include <base/new_menu.h>
15
16 #include "dialog/info_lister.h"
17 #ifdef __APPLE__
18 // malloc.h is deprecated, but malloc also lives in stdlib
19 #include <stdlib.h>
20 #else
21 #include <malloc.h>
22 #endif
23
24 #include "zalleg/zalleg.h"
25 #include "base/qrs.h"
26 #include "base/dmap.h"
27 #include "base/msgstr.h"
28 #include "base/packfile.h"
29 #include "base/cpool.h"
30 #include "base/autocombo.h"
31 #include "base/render.h"
32 #include "base/version.h"
33 #include "zq/autocombo/autopattern_base.h"
34 #include "zq/autocombo/pattern_basic.h"
35 #include "zq/autocombo/pattern_flatmtn.h"
36 #include "zq/autocombo/pattern_fence.h"
37 #include "zq/autocombo/pattern_cakemtn.h"
38 #include "zq/autocombo/pattern_relational.h"
39 #include "zq/autocombo/pattern_dungeoncarve.h"
40 #include "zq/autocombo/pattern_dormtn.h"
41 #include "zq/autocombo/pattern_tiling.h"
42 #include "zq/autocombo/pattern_replace.h"
43 #include "zq/render_hotkeys.h"
44 #include "zq/render_minimap.h"
45 #include "zq/render_tooltip.h"
46 #include "base/misctypes.h"
47 #include "parser/Compiler.h"
48 #include "base/zc_alleg.h"
49 #include "particles.h"
50 #include "dialog/combopool.h"
51 #include "dialog/alert.h"
52 #include "dialog/alertfunc.h"
53 #include "zq/gui/edit_autocombo.h"
54
55 9 particle_list particles;
56 9 void setZScriptVersion(int32_t) { } //bleh...
57
58 #include <al5_img.h>
59 #include <loadpng.h>
60 #include <fmt/format.h>
61
62 #include "dialog/cheat_codes.h"
63 #include "dialog/set_password.h"
64 #include "dialog/foodlg.h"
65 #include "dialog/quest_rules.h"
66 #include "dialog/script_rules.h"
67 #include "dialog/headerdlg.h"
68 #include "dialog/ffc_editor.h"
69 #include "dialog/screen_data.h"
70 #include "dialog/edit_dmap.h"
71 #include "dialog/compilezscript.h"
72 #include "dialog/externs.h"
73
74 #include "base/gui.h"
75 #include "gui/jwin_a5.h"
76 #include "zc_list_data.h"
77 #include "gui/editbox.h"
78 #include "zq/zq_misc.h"
79 #include "zq/zq_tiles.h" // tile and combo code
80
81 #include "zq/zquest.h"
82 #include "zq/zquestdat.h"
83 #include "zq/ffasm.h"
84 #include "zq/render.h"
85
86 // the following are used by both zelda.cc and zquest.cc
87 #include "base/zdefs.h"
88 #include "base/qrs.h"
89 #include "tiles.h"
90 #include "base/colors.h"
91 #include "base/qst.h"
92 #include "base/zsys.h"
93 #include "base/zapp.h"
94 #include "play_midi.h"
95 #include "sound/zcmusic.h"
96
97 #include "midi.h"
98 #include "sprite.h"
99 #include "fontsdat.h"
100 #include "base/jwinfsel.h"
101 #include "zq/zq_class.h"
102 #include "subscr.h"
103 #include "zq/zq_subscr.h"
104 #include "zc/ffscript.h"
105 #include "gui/EditboxNew.h"
106 #include "sfx.h"
107 #include "zq/zq_custom.h" // custom items and guys
108 #include "zq/zq_strings.h"
109 #include "zq/questReport.h"
110 #include "zq/ffasmexport.h"
111 #include <fstream>
112 #include "base/module.h"
113 #include "drawing.h"
114 #include "zconsole/ConsoleLogger.h"
115 #include "colorname.h"
116 #include "zq/zq_hotkey.h"
117 #include "zq/package.h"
118 #include "zq/zq_files.h"
119 #include "music_playback.h"
120
121 extern CConsoleLoggerEx parser_console;
122
123 namespace fs = std::filesystem;
124
125 //Windows mmemory tools
126 #ifdef _WIN32
127 #include <windows.h>
128 #include <stdio.h>
129 #include <psapi.h>
130 #pragma comment(lib, "psapi.lib") // Needed to avoid linker issues. -Z
131 #endif
132
133 #ifdef __EMSCRIPTEN__
134 #include <emscripten/emscripten.h>
135 #endif
136
137 //SDL_Surface *sdl_screen;
138
139 #if defined(ALLEGRO_WINDOWS)
140 static const char *data_path_name = "win_data_path";
141 static const char *midi_path_name = "win_midi_path";
142 static const char *image_path_name = "win_image_path";
143 static const char *tmusic_path_name = "win_tmusic_path";
144 static const char *last_quest_name = "win_last_quest";
145 static const char *qtname_name = "win_qtname%d";
146 static const char *qtpath_name = "win_qtpath%d";
147 #elif defined(ALLEGRO_LINUX)
148 static const char *data_path_name = "linux_data_path";
149 static const char *midi_path_name = "linux_midi_path";
150 static const char *image_path_name = "linux_image_path";
151 static const char *tmusic_path_name = "linux_tmusic_path";
152 static const char *last_quest_name = "linux_last_quest";
153 static const char *qtname_name = "linux_qtname%d";
154 static const char *qtpath_name = "linux_qtpath%d";
155 #elif defined(__APPLE__)
156 static const char *data_path_name = "macosx_data_path";
157 static const char *midi_path_name = "macosx_midi_path";
158 static const char *image_path_name = "macosx_image_path";
159 static const char *tmusic_path_name = "macosx_tmusic_path";
160 static const char *last_quest_name = "macosx_last_quest";
161 static const char *qtname_name = "macosx_qtname%d";
162 static const char *qtpath_name = "macosx_qtpath%d";
163 #endif
164
165 #include "base/win32.h"
166
167 #include "zq/zq_init.h"
168 #include "zq/zq_doors.h"
169 #include "zq/zq_cset.h"
170 #include "zinfo.h"
171
172 #ifdef _MSC_VER
173 #include <crtdbg.h>
174
175 #endif
176
177 // MSVC fix
178 #if _MSC_VER >= 1900
179 FILE _iob[] = { *stdin, *stdout, *stderr };
180 extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
181 #endif
182
183 extern byte monochrome_console;
184
185 #include "zconsole/ConsoleLogger.h"
186
187 extern CConsoleLoggerEx zscript_coloured_console;
188
189 uint8_t console_is_open = 0;
190 uint8_t __isZQuest = 1; //Shared functionscan reference this. -Z
191 bool is_zq_replay_test = false;
192
193 #include "base/util.h"
194
195 #ifdef __EMSCRIPTEN__
196 #include "base/emscripten_utils.h"
197 #endif
198
199 using namespace util;
200
201 using std::vector;
202 using std::map;
203 using std::stringstream;
204
205 9 FFScript FFCore;
206
207 void load_size_poses();
208 void do_previewtext();
209 bool do_slots(map<string, disassembled_script_data> &scripts, int assign_mode);
210 void do_script_disassembly(map<string, disassembled_script_data>& scripts, bool fromCompile);
211
212 int32_t startdmapxy[6] = {-1000, -1000, -1000, -1000, -1000, -1000};
213 bool cancelgetnum=false;
214
215 int32_t tooltip_timer=0, tooltip_maxtimer=30, tooltip_current_ffc=0;
216 int32_t mousecomboposition, combobrushoverride=-1;
217
218 int32_t original_playing_field_offset=0;
219 9 int32_t playing_field_offset=original_playing_field_offset;
220 int32_t passive_subscreen_height=56;
221 int32_t passive_subscreen_offset=0;
222
223 bool disable_saving=false, OverwriteProtection;
224 bool halt=false;
225 bool show_sprites=true;
226 bool show_hitboxes = false;
227 bool zq_ignore_item_ownership = true;
228
229 // Used to find FFC script names
230 vector<string> asffcscripts;
231 vector<string> asglobalscripts;
232 vector<string> asitemscripts;
233 vector<string> asnpcscripts;
234 vector<string> aseweaponscripts;
235 vector<string> aslweaponscripts;
236 vector<string> asplayerscripts;
237 vector<string> asdmapscripts;
238 vector<string> asscreenscripts;
239 vector<string> asitemspritescripts;
240 vector<string> ascomboscripts;
241 vector<string> asgenericscripts;
242 vector<string> assubscreenscripts;
243
244 vector<string> ZQincludePaths;
245
246 int32_t CSET_SIZE = 16;
247 int32_t CSET_SHFT = 4;
248 //editbox_data temp_eb_data;
249 /*
250 #define CSET(x) ((x)<<CSET_SHFT)
251 #define csBOSS 14
252 */
253
254 /*
255 enum { m_block, m_coords, m_flags, m_guy, m_warp, m_misc, m_layers,
256 m_menucount };
257 */
258 void update_combo_cycling();
259 void update_freeform_combos();
260
261 /*
262 #define MAXMICE 14
263 #define MAXARROWS 8
264 #define SHADOW_DEPTH 2
265 */
266 int32_t coord_timer=0, coord_frame=0;
267 int32_t blackout_color, zq_screen_w, zq_screen_h;
268 int32_t draw_mode=0;
269
270 9 size_and_pos minimap;
271 9 size_and_pos real_minimap;
272
273 9 size_and_pos minimap_zoomed;
274 9 size_and_pos real_minimap_zoomed;
275
276 9 size_and_pos map_page_bar[9];
277 int32_t mappage_count = 9;
278
279 9 size_and_pos combolist[MAX_COMBO_COLS];
280 9 size_and_pos combolistscrollers[MAX_COMBO_COLS];
281 int32_t num_combo_cols = MAX_COMBO_COLS;
282
283 9 size_and_pos compactbtn;
284 9 size_and_pos mainbar;
285
286 9 size_and_pos screrrorpos;
287
288 9 size_and_pos comboaliaslist[MAX_COMBO_COLS];
289 9 size_and_pos comboalias_preview;
290 9 size_and_pos combopool_preview;
291 9 size_and_pos combopool_prevbtn;
292
293 9 size_and_pos combo_merge_btn;
294
295 9 size_and_pos combo_preview;
296 9 size_and_pos combo_preview2;
297 9 size_and_pos combo_preview_text1;
298 9 size_and_pos combo_preview_text2;
299 9 size_and_pos combolist_window;
300 9 size_and_pos drawmode_btn;
301 9 size_and_pos main_panel;
302 9 size_and_pos squares_panel;
303 9 size_and_pos preview_panel;
304 9 size_and_pos layer_panel;
305 9 size_and_pos preview_text;
306
307 9 size_and_pos favorites_window;
308 9 size_and_pos favorites_list;
309 9 size_and_pos favorites_x;
310 9 size_and_pos favorites_infobtn;
311 9 size_and_pos favorites_zoombtn;
312 9 size_and_pos favorites_pgleft;
313 9 size_and_pos favorites_pgright;
314
315 9 size_and_pos commands_window;
316 9 size_and_pos commands_list;
317 9 size_and_pos commands_x;
318 9 size_and_pos commands_infobtn;
319 9 size_and_pos commands_zoombtn;
320 9 size_and_pos commands_txt;
321
322 9 size_and_pos squarepanel_swap_btn;
323 9 size_and_pos squarepanel_up_btn;
324 9 size_and_pos squarepanel_down_btn;
325 9 size_and_pos itemsqr_pos;
326 9 size_and_pos flagsqr_pos;
327 9 size_and_pos stairsqr_pos;
328 9 size_and_pos warparrival_pos;
329 9 size_and_pos warpret_pos[4];
330 9 size_and_pos enemy_prev_pos;
331
332 9 size_and_pos txtoffs_single;
333 9 size_and_pos txtoffs_double_1;
334 9 size_and_pos txtoffs_double_2;
335 int32_t panel_align = 1;
336
337 int32_t command_buttonwidth = 88;
338 int32_t command_buttonheight = 19;
339
340 int32_t layerpanel_buttonwidth = 58;
341 int32_t layerpanel_buttonheight = 16;
342
343 int32_t layerpanel_checkbox_hei = 13;
344 int32_t layerpanel_checkbox_wid = 13;
345
346 int32_t favorite_combos[MAXFAVORITECOMBOS];
347 byte favorite_combo_modes[MAXFAVORITECOMBOS];
348 bool ShowFavoriteComboModes;
349 byte FavoriteComboPage;
350
351 char comboprev_buf[512] = {0};
352 char comboprev_buf2[512] = {0};
353 FONT* txfont;
354
355 const char *roomtype_string[MAXROOMTYPES] =
356 {
357 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
358 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
359 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
360 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
361 };
362
363 const char *catchall_string[MAXROOMTYPES] =
364 {
365 "Generic Catchall","Special Item","Info Type","Amount","Generic Catchall","Repair Fee","Generic Catchall","Generic Catchall","Generic Catchall","Shop Type",
366 "Shop Type","Price","Price","Generic Catchall","Warp Ring","Generic Catchall","Generic Catchall", "Generic Catchall", "Generic Catchall",
367 "Generic Catchall", "Price","Shop Type","Bottle Shop Type"
368 };
369
370 #define MAXPOOLCOMBOS MAXFAVORITECOMBOS
371
372 struct cmbdat_pair
373 {
374 int32_t data;
375 byte cset;
376 11340 cmbdat_pair() { clear(); }
377 18900 void clear()
378 {
379 18900 data = -1;
380 18900 cset = 0;
381 18900 }
382 bool valid() const
383 {
384 return data > -1;
385 }
386 };
387 bool pool_dirty=true;
388 9 cmbdat_pair pool_combos[MAXPOOLCOMBOS];
389 static std::vector<byte> pool;
390
391 bool pool_valid()
392 {
393 if(pool_dirty)
394 {
395 pool.clear();
396 for(auto q = 0; q < MAXPOOLCOMBOS; ++q)
397 {
398 if(pool_combos[q].valid())
399 pool.push_back(q);
400 }
401 pool_dirty = false;
402 }
403 return pool.size() > 0;
404 }
405 cmbdat_pair const& get_pool_combo()
406 {
407 if(!pool_valid()) return pool_combos[0];
408 auto ind = zc_rand(pool.size()-1);
409 return pool_combos[pool.at(ind)];
410 }
411
412 int32_t mapscreen_x, mapscreen_y, mapscreensize, showedges, showallpanels;
413 int32_t mouse_scroll_h;
414
415
416 int32_t readsize, writesize;
417 bool fake_pack_writing=false;
418
419 int32_t showxypos_x;
420 int32_t showxypos_y;
421 int32_t showxypos_w;
422 int32_t showxypos_h;
423 int32_t showxypos_color;
424 int32_t showxypos_ffc=-1000;
425 bool showxypos_icon=false;
426
427 int32_t showxypos_cursor_x;
428 int32_t showxypos_cursor_y;
429 bool showxypos_cursor_icon=false;
430 int32_t showxypos_cursor_color;
431 bool showxypos_dummy = false;
432
433 bool canfill=true; //to prevent double-filling (which stops undos)
434 bool resize_mouse_pos=false; //for eyeball combos
435 int32_t lens_hint_item[MAXITEMS][2]; //aclk, aframe
436 int32_t lens_hint_weapon[MAXWPNS][5]; //aclk, aframe, dir, x, y
437 //int32_t mode, switch_mode, orig_mode;
438 int32_t tempmode=GFX_AUTODETECT;
439 RGB_MAP zq_rgb_table;
440 COLOR_MAP trans_table, trans_table2;
441 DATAFILE *zcdata=NULL;
442 MIDI *song=NULL;
443 BITMAP *menu1, *menu3, *mapscreenbmp, *tmp_scr, *screen2, *mouse_bmp[MOUSE_BMP_MAX][4], *mouse_bmp_1x[MOUSE_BMP_MAX][4], *icon_bmp[ICON_BMP_MAX][4], *flag_bmp[16][4], *select_bmp[2], *dmapbmp_small, *dmapbmp_large;
444 BITMAP *arrow_bmp[MAXARROWS],*brushbmp, *brushscreen; //*brushshadowbmp;
445 byte *colordata=NULL, *trashbuf=NULL;
446 itemdata *itemsbuf;
447 wpndata *wpnsbuf;
448 comboclass *combo_class_buf;
449 guydata *guysbuf;
450 item_drop_object item_drop_sets[MAXITEMDROPSETS];
451 9 newcombo curr_combo;
452 PALETTE RAMpal;
453 midi_info Midi_Info;
454 bool zq_showpal=false;
455 bool combo_cols=true;
456 bool is_compact = false;
457
458 int pixeldb = 1;
459 int infobg = 1;
460 bool large_merged_combopane = false;
461 bool compact_merged_combopane = true;
462 bool large_zoomed_fav = false;
463 bool compact_zoomed_fav = true;
464 bool large_zoomed_cmd = false;
465 bool compact_zoomed_cmd = true;
466
467 bool compact_square_panels = false;
468 int compact_active_panel = 0;
469
470 int combo_col_scale = 1;
471
472 std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
473 script_data *ffscripts[NUMSCRIPTFFC];
474 script_data *itemscripts[NUMSCRIPTITEM];
475 script_data *guyscripts[NUMSCRIPTGUYS];
476 script_data *lwpnscripts[NUMSCRIPTWEAPONS];
477 script_data *ewpnscripts[NUMSCRIPTWEAPONS];
478 script_data *globalscripts[NUMSCRIPTGLOBAL];
479 script_data *genericscripts[NUMSCRIPTSGENERIC];
480 script_data *playerscripts[NUMSCRIPTPLAYER];
481 script_data *screenscripts[NUMSCRIPTSCREEN];
482 script_data *dmapscripts[NUMSCRIPTSDMAP];
483 script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
484 script_data *comboscripts[NUMSCRIPTSCOMBODATA];
485 script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
486
487 extern string zScript;
488 char zScriptBytes[512];
489 char zLastVer[512] = { 0 };
490 SAMPLE customsfxdata[WAV_COUNT];
491 uint8_t customsfxflag[WAV_COUNT>>3];
492 int32_t sfxdat=1;
493
494 int32_t onImport_ComboAlias();
495 int32_t onExport_ComboAlias();
496
497 void set_console_state();
498
499 void clearConsole()
500 {
501 if(!console_is_open) return;
502 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
503 zscript_coloured_console.gotoxy(0,0);
504 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
505 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
506 }
507
508 void initConsole()
509 {
510 if(console_is_open) return;
511 console_is_open = 1;
512 set_console_state();
513 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
514 clearConsole();
515 }
516
517 9 void killConsole()
518 {
519
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!console_is_open) return;
520 console_is_open = 0;
521 set_console_state();
522 zscript_coloured_console.kill();
523 9 }
524
525 int toggleConsole()
526 {
527 console_is_open ? killConsole() : initConsole();
528 zc_set_config("zquest","open_debug_console",console_is_open?1:0);
529 return D_O_K;
530 }
531
532 int showHotkeys()
533 {
534 hotkeys_toggle_display(!hotkeys_is_active());
535 return D_O_K;
536 }
537
538 typedef int32_t (*intF)();
539 typedef struct command_pair
540 {
541 char name[80];
542 int32_t flags;
543 intF command;
544 } command_pair;
545
546 extern map_and_screen map_page[MAX_MAPPAGE_BTNS];
547
548 int32_t do_OpenQuest()
549 {
550 return onOpen();
551 }
552
553 int32_t do_NewQuest()
554 {
555 //clear the panel recent screen buttons to prevent crashes from invalid maps
556 for ( int32_t q = 0; q < 9; q++ )
557 {
558 map_page[q].map = 0;
559 map_page[q].screen = 0;
560 }
561 Map.setCurrMap(0);
562 Map.setCurrScr(0);
563 return onNew();
564 }
565
566 extern int CheckerCol1, CheckerCol2;
567 int32_t alignment_arrow_timer=0;
568 int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
569 int32_t Flags=0,Flag=0,menutype=(m_block);
570 int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, GridColor = 15,
571 CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
572 TileProtection = 0, ComboProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
573 LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
574 EnableTooltips = 0, TooltipsHighlight = 0, ShowFFScripts = 0, ShowSquares = 0,
575 ShowFFCs = 0, ShowInfo = 0, skipLayerWarning = 0, WarnOnInitChanged = 0,
576 DisableLPalShortcuts = 1, DisableCompileConsole = 0, numericalFlags = 0,
577 ActiveLayerHighlight = 0;
578 uint8_t InvalidBG = 0;
579 bool NoHighlightLayer0 = false;
580 int32_t FlashWarpSquare = -1, FlashWarpClk = 0; // flash the destination warp return when ShowSquares is active
581 uint8_t ViewLayer3BG = 0, ViewLayer2BG = 0;
582 int32_t window_width, window_height;
583 bool ShowFPS = false, SaveDragResize = false, DragAspect = false, SaveWinPos=false;
584 bool allowHideMouse = false;
585 double aspect_ratio = LARGE_H / double(LARGE_W);
586 int window_min_width = 0, window_min_height = 0;
587 int32_t ComboBrush = 0; //show the brush instead of the normal mouse
588 int32_t ComboBrushPause = 0; //temporarily disable the combo brush
589 int32_t FloatBrush = 0; //makes the combo brush float a few pixels up and left
590 int AutoBrush = 0; //Drag to size the brush on the combo panes
591 bool AutoBrushRevert = false; //Revert after placing
592 int LinkedScroll = 0;
593 //complete with shadow
594 int32_t OpenLastQuest = 0; //makes the program reopen the quest that was
595 //open at the time you quit
596 int32_t ShowMisalignments = 0; //makes the program display arrows over combos that are
597 //not aligned with the next screen.
598 int32_t AnimationOn = 0; //animate the combos in zquest?
599 int32_t AutoBackupRetention = 0; //use auto-backup feature? if so, how many backups (1-10) to keep
600 int32_t AutoSaveInterval = 0; //how often a timed autosave is made (not overwriting the current file)
601 int32_t UncompressedAutoSaves = 0; //should timed saves be uncompressed/encrypted?
602 int32_t KeyboardRepeatDelay = 0; //the time in milliseconds after holding down a key that the key starts to repeat
603 int32_t KeyboardRepeatRate = 0; //the time in milliseconds between each repetition of a repeated key
604
605 time_t auto_save_time_start, auto_save_time_current;
606 double auto_save_time_diff = 0;
607 int32_t AutoSaveRetention = 0; //how many autosaves of a quest to keep
608 int32_t ImportMapBias = 0; //tells what has precedence on map importing
609 int32_t BrushWidth=1, BrushHeight=1;
610 bool saved=true;
611 bool __debug=false;
612 //bool usetiles=true;
613 int32_t LayerMaskInt[7]={0};
614 int32_t CurrentLayer=0;
615 int32_t DuplicateAction[4]={0};
616 int32_t OnlyCheckNewTilesForDuplicates = 0;
617 int32_t try_recovering_missing_scripts = 0;
618
619 uint8_t PreFillTileEditorPage = 0, PreFillComboEditorPage = 0;
620 int32_t DMapEditorLastMaptileUsed = 0;
621
622 /*
623 , HorizontalDuplicateAction;
624 int32_t VerticalDuplicateAction, BothDuplicateAction;
625 */
626 word msg_count = 0;
627 int32_t LeechUpdate = 0;
628 int32_t LeechUpdateTiles = 0;
629 int32_t SnapshotFormat = 0;
630 byte SnapshotScale = 0;
631
632 byte Color = 0;
633 extern int32_t jwin_pal[jcMAX];
634 int32_t gui_colorset=99;
635
636 static int32_t combo_apos=0; //currently selected combo alias
637 int32_t alias_origin=0;
638 int32_t alias_cset_mod=0;
639
640 static int32_t combo_pool_pos=0; //currently selected combo pool
641 bool weighted_cpool = true;
642 bool cpool_prev_visible = false;
643
644 static int32_t combo_auto_pos=0; //currently selected autocombo
645 byte cauto_height = 1;
646
647 bool trip=false;
648
649 int32_t fill_type=1;
650
651 bool first_save=false;
652 char *filepath,*midipath,*datapath,*imagepath,*tmusicpath,*last_timed_save;
653 string helpstr, zstringshelpstr;
654
655 ZCMUSIC *zcmusic = NULL;
656 ZCMIXER *zcmixer = NULL;
657 int32_t midi_volume = 255;
658 extern int32_t prv_mode;
659 int32_t prv_warp = 0;
660 int32_t prv_twon = 0;
661 int32_t ff_combo = 0;
662
663 int32_t Frameskip = 0, RequestedFPS = 60, zqUseWin32Proc = 1;
664 int32_t zqColorDepth = 8;
665 int32_t joystick_index=0;
666
667 9 void set_last_timed_save(char const* buf)
668 {
669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if(buf && buf[0])
670 {
671 if(buf != last_timed_save)
672 strcpy(last_timed_save, buf);
673 }
674 else
675 {
676 9 last_timed_save[0] = 0;
677 9 buf = nullptr;
678 }
679 9 zc_set_config("zquest","last_timed_save",buf);
680 9 }
681
682 void loadlvlpal(int32_t level);
683 bool get_debug()
684 {
685 return __debug;
686 //return true;
687 }
688
689 void set_debug(bool d)
690 {
691 __debug=d;
692 return;
693 }
694
695 bool handle_quit()
696 {
697 if(onExit()==D_CLOSE)
698 return (exiting_program = true);
699 return false;
700 }
701 bool handle_close_btn_quit()
702 {
703 if(close_button_quit)
704 {
705 close_button_quit=false;
706 return handle_quit();
707 }
708 return false;
709 }
710 // **** Timers ****
711
712 volatile int32_t lastfps=0;
713 volatile int32_t framecnt=0;
714 size_t cpoolbrush_index = 0;
715
716 // quest data
717 zquestheader header;
718 byte midi_flags[MIDIFLAGS_SIZE];
719 byte music_flags[MUSICFLAGS_SIZE];
720 byte *quest_file;
721 int32_t msg_strings_size;
722 zctune *customtunes;
723 //emusic *enhancedMusic;
724 ZCHEATS zcheats;
725 byte use_cheats;
726 byte use_tiles;
727 // Note: may not be null-terminated (must refactor writecolordata to fix).
728 char palnames[MAXLEVELS][17];
729 char zquestdat_sig[52];
730 char qstdat_str[2048];
731
732 int32_t gme_track=0;
733
734 int32_t dlevel; // just here until gamedata is properly done
735
736 10 bool bad_version(int32_t ver)
737 {
738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(ver < 0x170)
739 return true;
740
741 10 return false;
742 10 }
743
744 zfix HeroModifiedX()
745 {
746 if(resize_mouse_pos)
747 {
748 return (zfix)((gui_mouse_x()/mapscreensize)-((8*mapscreensize)-1)+(showedges?8:0));
749 }
750 else
751 {
752 return (zfix)(gui_mouse_x()-7);
753 }
754 }
755
756 zfix HeroModifiedY()
757 {
758 if(resize_mouse_pos)
759 {
760 return (zfix)((gui_mouse_y()/mapscreensize)-((8*mapscreensize)-1)-16+(showedges?16:0));
761 }
762 else
763 {
764 return (zfix)(gui_mouse_y()-7);
765 }
766 }
767
768
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu import_250_menu
769 36 {
770
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&DMaps", onImport_DMaps },
771
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Table", onImport_Combos },
772
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Alias", onImport_ComboAlias },
773 };
774
775
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu import_graphics
776 135 {
777
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palettes", onImport_Pals },
778
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
779
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Tileset (&Full)", onImport_Tiles },
780
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tile Pack", onImport_Tilepack },
781
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "T&ile Pack to...", onImport_Tilepack_To },
782
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
783
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Set (Range)", onImport_Combos },
784
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo Pack (Full, 1:1)", onImport_Combopack },
785
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo Pack to... (Dest)", onImport_Combopack_To },
786
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
787
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo &Alias Pack", onImport_Comboaliaspack },
788
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo A&lias Pack to...", onImport_Comboaliaspack_To },
789
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
790
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Doorsets", onImport_Doorset },
791 };
792
793
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu import_menu
794 90 {
795
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemies", onImport_Guys },
796
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Map", onImport_Map },
797
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&DMaps", onImport_DMaps },
798
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Strings (.tsv)", onImport_StringsTSV },
799
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "String Table (deprecated)", onImport_Msgs },
800
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
801
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Graphics", &import_graphics },
802
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
803
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2.50 (Broken)", &import_250_menu },
804 };
805
806
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu export_250_menu
807 45 {
808
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&DMaps", onExport_DMaps },
809
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Table", onExport_Combos },
810
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Alias", onExport_ComboAlias },
811
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Graphics Pack", onExport_ZGP },
812 };
813
814
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu zq_help_menu
815 27 {
816
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Editor Help", onHelp },
817
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Strings Help", onZstringshelp },
818 };
819
820
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu export_graphics
821 108 {
822
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palettes", onExport_Pals },
823
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
824
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Tileset (&Full)", onExport_Tiles },
825
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tile Pack", onExport_Tilepack },
826
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
827
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Set", onExport_Combos },
828
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo Pack", onExport_Combopack },
829
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
830
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo &Alias Pack", onExport_Comboaliaspack },
831
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
832
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Doorsets", onExport_Doorset },
833 };
834
835
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu export_menu
836 99 {
837 #ifdef _WIN32
838 { "&Package", onExport_Package },
839 #endif
840
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemies", onExport_Guys },
841
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Map", onExport_Map },
842
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&DMaps", onExport_DMaps },
843
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
844
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Strings (.tsv)", onExport_StringsTSV },
845
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "String Table (deprecated)", onExport_Msgs },
846
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
847
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Graphics", &export_graphics },
848
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
849
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2.50 (Broken)", &export_250_menu },
850 };
851
852
853
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu recent_menu
854 99 {
855
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
856
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
857
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
858
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
859
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
860
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
861
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
862
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
863
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
864
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
865 };
866 static char rec_menu_fullpaths[10][512];
867 static char rec_menu_strs[10][64];
868
869 int32_t customOpen(char const* path);
870 void do_recent_quest(uint32_t ind)
871 {
872 if(ind > 9) return;
873 strcpy(temppath, rec_menu_fullpaths[ind]);
874 customOpen(temppath);
875 }
876 int32_t do_RecentQuest_0() { do_recent_quest(0); return D_O_K; }
877 int32_t do_RecentQuest_1() { do_recent_quest(1); return D_O_K; }
878 int32_t do_RecentQuest_2() { do_recent_quest(2); return D_O_K; }
879 int32_t do_RecentQuest_3() { do_recent_quest(3); return D_O_K; }
880 int32_t do_RecentQuest_4() { do_recent_quest(4); return D_O_K; }
881 int32_t do_RecentQuest_5() { do_recent_quest(5); return D_O_K; }
882 int32_t do_RecentQuest_6() { do_recent_quest(6); return D_O_K; }
883 int32_t do_RecentQuest_7() { do_recent_quest(7); return D_O_K; }
884 int32_t do_RecentQuest_8() { do_recent_quest(8); return D_O_K; }
885 int32_t do_RecentQuest_9() { do_recent_quest(9); return D_O_K; }
886
887 2 void refresh_recent_menu()
888 {
889 2 int32_t (*procs[10])(void) = {
890 do_RecentQuest_0, do_RecentQuest_1, do_RecentQuest_2, do_RecentQuest_3,
891 do_RecentQuest_4, do_RecentQuest_5, do_RecentQuest_6,
892 do_RecentQuest_7, do_RecentQuest_8, do_RecentQuest_9
893 };
894
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 static MenuItem nilitem("---",nullptr,nullopt,true);
895
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 for(auto q = 0; q < 10; ++q)
896 {
897 20 MenuItem& mit = *recent_menu.at(q);
898 20 bool valid = rec_menu_fullpaths[q][0] != '-';
899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(valid)
900 mit = MenuItem(rec_menu_strs[q],procs[q]);
901 20 else mit = nilitem;
902 20 }
903 2 }
904
905 1 void load_recent_quests()
906 {
907 1 char configname[64] = "rec_qst_";
908 1 char* ptr = &configname[strlen(configname)];
909 1 char buf[512] = {0};
910
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for(auto q = 0; q < 10; ++q)
911 {
912 10 sprintf(ptr, "%d", q); //increment the configname value
913 10 char const* qst_str = zc_get_config("recent",configname,nullptr);
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(qst_str[0])
915 {
916 strncpy(rec_menu_fullpaths[q], qst_str, 511);
917 relativize_path(buf, rec_menu_fullpaths[q]);
918 if(strlen(buf) > 62)
919 {
920 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
921 }
922 strncpy(rec_menu_strs[q], buf, 63);
923 }
924 else
925 {
926 10 strcpy(rec_menu_fullpaths[q], "---");
927 10 strcpy(rec_menu_strs[q], "---");
928 }
929 10 rec_menu_fullpaths[q][511] = 0;
930 10 rec_menu_strs[q][63] = 0;
931 10 }
932 1 refresh_recent_menu();
933 1 }
934
935 void write_recent_quests()
936 {
937 char configname[64] = "rec_qst_";
938 char* ptr = &configname[strlen(configname)];
939 for(auto q = 0; q < 10; ++q)
940 {
941 sprintf(ptr, "%d", q); //increment the configname value
942 zc_set_config("recent",configname,(rec_menu_fullpaths[q][0]!='-') ? rec_menu_fullpaths[q] : nullptr);
943 }
944 }
945
946 void update_recent_quest(char const* path)
947 {
948 int32_t ind = -1;
949 for(auto q = 0; q < 10; ++q)
950 {
951 if(!strcmp(path, rec_menu_fullpaths[q]))
952 {
953 ind = q;
954 break;
955 }
956 }
957 if(ind > -1)
958 {
959 for(auto q = ind; q > 0; --q)
960 {
961 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
962 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
963 }
964 }
965 else
966 {
967 int32_t free_ind = 9; //if none found, override the last index
968 for(auto q = 0; q < 9; ++q)
969 {
970 if(rec_menu_fullpaths[q][0] == '-')
971 {
972 free_ind = q;
973 break;
974 }
975 }
976
977 for(auto q = free_ind; q > 0; --q)
978 {
979 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
980 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
981 }
982 }
983 char buf[512] = {0};
984 strcpy(rec_menu_fullpaths[0], path);
985 relativize_path(buf, rec_menu_fullpaths[0]);
986 if(strlen(buf) > 62)
987 {
988 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
989 }
990 strncpy(rec_menu_strs[0], buf, 63);
991 refresh_recent_menu();
992 zc_set_config("zquest",last_quest_name,path);
993 write_recent_quests();
994 }
995
996 void reload_zq_gui()
997 {
998 init_custom_fonts();
999 load_size_poses();
1000 update_combobrush();
1001 refresh(rCLEAR|rALL);
1002 }
1003 void toggle_is_compact()
1004 {
1005 is_compact = !is_compact;
1006 zc_set_config("ZQ_GUI","compact_mode",is_compact?1:0);
1007 reload_zq_gui();
1008 }
1009 void toggle_merged_mode()
1010 {
1011 if(is_compact)
1012 {
1013 compact_merged_combopane = !compact_merged_combopane;
1014 zc_set_config("ZQ_GUI","merge_cpane_compact",compact_merged_combopane?1:0);
1015 }
1016 else
1017 {
1018 large_merged_combopane = !large_merged_combopane;
1019 zc_set_config("ZQ_GUI","merge_cpane_large",large_merged_combopane?1:0);
1020 }
1021 reload_zq_gui();
1022 }
1023 void toggle_compact_sqr_mode()
1024 {
1025 compact_square_panels = !compact_square_panels;
1026 zc_set_config("ZQ_GUI","square_panels_compact",compact_square_panels?1:0);
1027 reload_zq_gui();
1028 }
1029 void cycle_compact_sqr(bool down)
1030 {
1031 if(!(is_compact && compact_square_panels))
1032 return;
1033 static const int num_panels = 3;
1034 if(down)
1035 compact_active_panel = (compact_active_panel+1)%num_panels;
1036 else
1037 compact_active_panel = (compact_active_panel-1+num_panels)%num_panels;
1038 reload_zq_gui();
1039 }
1040 void toggle_favzoom_mode()
1041 {
1042 if(is_compact)
1043 {
1044 compact_zoomed_fav = !compact_zoomed_fav;
1045 zc_set_config("ZQ_GUI","zoom_fav_compact",compact_zoomed_fav?1:0);
1046 }
1047 else
1048 {
1049 large_zoomed_fav = !large_zoomed_fav;
1050 zc_set_config("ZQ_GUI","zoom_fav_large",large_zoomed_fav?1:0);
1051 }
1052 reload_zq_gui();
1053 }
1054 void toggle_cmdzoom_mode()
1055 {
1056 if(is_compact)
1057 {
1058 compact_zoomed_cmd = !compact_zoomed_cmd;
1059 zc_set_config("ZQ_GUI","zoom_cmd_compact",compact_zoomed_cmd?1:0);
1060 }
1061 else
1062 {
1063 large_zoomed_cmd = !large_zoomed_cmd;
1064 zc_set_config("ZQ_GUI","zoom_cmd_large",large_zoomed_cmd?1:0);
1065 }
1066 reload_zq_gui();
1067 }
1068
1069 enum
1070 {
1071 MENUID_FILE_SAVE,
1072 MENUID_FILE_SAVEAS,
1073 MENUID_FILE_REVERT,
1074 };
1075
1076
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu file_menu
1077 126 {
1078
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&New", do_NewQuest },
1079
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Open", do_OpenQuest },
1080
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Load Tileset", onTileset },
1081
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Recent", &recent_menu },
1082
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1083
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Save", onSave, MENUID_FILE_SAVE },
1084
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Save &as...", onSaveAs, MENUID_FILE_SAVEAS },
1085
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Revert", onRevert, MENUID_FILE_REVERT },
1086
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1087
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Import", &import_menu },
1088
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Export", &export_menu },
1089 #ifndef __EMSCRIPTEN__
1090
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1091
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "E&xit", handle_quit },
1092 #endif
1093 };
1094
1095 enum
1096 {
1097 MENUID_MAPS_NEXT,
1098 MENUID_MAPS_PREV,
1099 };
1100
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu maps_menu
1101 54 {
1102
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Goto Map...", onGotoMap },
1103
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Next Map", onIncMap, MENUID_MAPS_NEXT },
1104
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Previous Map", onDecMap, MENUID_MAPS_PREV },
1105
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1106
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "D&elete Map", onDeleteMap },
1107 };
1108
1109
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu misc_menu
1110 90 {
1111
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "S&ubscreens", onEditSubscreens },
1112
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Shop Types", onShopTypes },
1113
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Bottle Types", onBottleTypes },
1114
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Bottle S&hop Types", onBottleShopTypes },
1115
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Info Types", onInfoTypes },
1116
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Warp Rings", onWarpRings },
1117
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Triforce Pieces", onTriPieces },
1118
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&End String", onEndString },
1119
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Item &Drop Sets", onItemDropSets },
1120 };
1121
1122
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu spr_menu
1123 36 {
1124
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Sprite Data", onCustomWpns },
1125
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Player", onCustomHero },
1126
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Misc Sprites", onMiscSprites },
1127 };
1128
1129
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 NewMenu colors_menu
1130 36 {
1131
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Main ", onColors_Main },
1132
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Levels ", onColors_Levels },
1133
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Sprites ", onColors_Sprites },
1134 };
1135
1136
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu defs_menu
1137 81 {
1138
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palettes", onDefault_Pals },
1139
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tiles", onDefault_Tiles },
1140
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combos", onDefault_Combos },
1141
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Items", onDefault_Items },
1142
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemies", onDefault_Guys },
1143
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Sprite Data", onDefault_Weapons },
1144
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Map Styles", onDefault_MapStyles },
1145
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "SF&X Data", onDefault_SFX },
1146 };
1147
1148 int32_t onEditComboAlias();
1149 int32_t onEditComboPool();
1150 int32_t onEditAutoCombo();
1151
1152
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu graphics_menu
1153 90 {
1154
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palettes ", &colors_menu },
1155
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Sprites ", &spr_menu },
1156
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combos", onCombos },
1157
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tiles", onTiles },
1158
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Game icons", onIcons },
1159
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Misc co&lors", onMiscColors },
1160
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Map styles", onMapStyles },
1161
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Door Combo Sets", onDoorCombos },
1162
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo &Aliases", onEditComboAlias },
1163 };
1164
1165
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu audio_menu
1166 36 {
1167
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "SF&X Data", onSelectSFX },
1168
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&MIDIs", onMidis },
1169
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Mis&c SFX", onMiscSFX },
1170 };
1171
1172 void set_rules(byte* newrules);
1173
1174 void call_testqst_dialog();
1175 int32_t onTestQst()
1176 {
1177 call_testqst_dialog();
1178 return D_O_K;
1179 }
1180
1181 int32_t onRulesDlg()
1182 {
1183 call_qr_dialog(21, set_rules);
1184 return D_O_K;
1185 }
1186
1187 int32_t onRulesSearch()
1188 {
1189 call_qrsearch_dialog(set_rules);
1190 return D_O_K;
1191 }
1192
1193 int32_t onZScriptSettings()
1194 {
1195 ScriptRulesDialog(quest_rules, 17, [](byte* newrules)
1196 {
1197 saved = false;
1198 memcpy(quest_rules, newrules, QR_SZ);
1199 unpack_qrs();
1200 }).show();
1201 return D_O_K;
1202 }
1203
1204 void call_zinf_dlg();
1205 int32_t onZInfo()
1206 {
1207 call_zinf_dlg();
1208 return D_O_K;
1209 }
1210
1211
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu quest_menu
1212 144 {
1213
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Options ", onRulesDlg },
1214
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Test", onTestQst },
1215
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Items", onCustomItems },
1216
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Ene&mies", onCustomEnemies },
1217
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Player", onCustomHero },
1218
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Strings", onStrings },
1219
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&DMaps", onDmaps },
1220
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "I&nit Data", onInit },
1221
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Misc D&ata ", &misc_menu },
1222
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&ZInfo", onZInfo },
1223
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1224
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Graphics ", &graphics_menu },
1225
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "A&udio ", &audio_menu },
1226
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1227
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "De&faults ", &defs_menu },
1228 };
1229
1230
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu paste_menu
1231 27 {
1232
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste &To All", onPasteToAll },
1233
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste &All To All", onPasteAllToAll },
1234 };
1235
1236
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu paste_item_menu
1237 117 {
1238
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Undercombo", onPasteUnderCombo },
1239
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Secret Combos", onPasteSecretCombos },
1240
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Freeform Combos", onPasteFFCombos },
1241
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Screen &Data", onPasteScreenData },
1242
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Warps", onPasteWarps },
1243
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Warp &Return", onPasteWarpLocations },
1244
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemies", onPasteEnemies },
1245
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Room &Type Data", onPasteRoom },
1246
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Guy/String", onPasteGuy },
1247
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Doo&rs", onPasteDoors },
1248
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Layers", onPasteLayers },
1249
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palette", onPastePalette },
1250 };
1251
1252 enum
1253 {
1254 MENUID_EDIT_UNDO,
1255 MENUID_EDIT_REDO,
1256 MENUID_EDIT_COPY,
1257 MENUID_EDIT_PASTE,
1258 MENUID_EDIT_PASTEALL,
1259 MENUID_EDIT_ADVPASTE,
1260 MENUID_EDIT_SPECPASTE,
1261 MENUID_EDIT_DELETE,
1262 };
1263
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu edit_menu
1264 99 {
1265
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Undo", onUndo, MENUID_EDIT_UNDO },
1266
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Redo", onRedo, MENUID_EDIT_REDO },
1267
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Copy", onCopy, MENUID_EDIT_COPY },
1268
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Paste", onPaste, MENUID_EDIT_PASTE },
1269
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste A&ll", onPasteAll, MENUID_EDIT_PASTEALL },
1270
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Adv. Paste ", &paste_menu, MENUID_EDIT_ADVPASTE },
1271
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste &Spec. ", &paste_item_menu, MENUID_EDIT_SPECPASTE },
1272
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Delete", onDelete, MENUID_EDIT_DELETE },
1273
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1274
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Maps ", &maps_menu },
1275 };
1276
1277
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu drawing_mode_menu
1278 45 {
1279
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Normal", onDrawingModeNormal, dm_normal },
1280
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Alias", onDrawingModeAlias, dm_alias },
1281
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Pool", onDrawingModePool, dm_cpool },
1282
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Auto Combo", onDrawingModeAuto, dm_auto },
1283 };
1284
1285
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu integrity_check_menu
1286 36 {
1287
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&All ", onIntegrityCheckAll },
1288
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Screens ", onIntegrityCheckRooms },
1289
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Warps ", onIntegrityCheckWarps },
1290 };
1291
1292
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu quest_reports_menu
1293 81 {
1294
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Bugged Next-> Combo Locations", onBuggedNextComboLocationReport },
1295
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Locations", onComboLocationReport },
1296
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Combo Type Locations", onComboTypeLocationReport },
1297
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemy Locations", onEnemyLocationReport },
1298
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Item Locations", onItemLocationReport },
1299
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Script Locations", onScriptLocationReport },
1300
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&What Links Here", onWhatWarpsReport },
1301
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "In&tegrity Check ", &integrity_check_menu },
1302 };
1303
1304 int32_t onPalFix();
1305 int32_t onPitFix();
1306 int32_t onStrFix()
1307 {
1308 if(get_qr(qr_OLD_STRING_EDITOR_MARGINS))
1309 {
1310 AlertDialog("Fix: Old Margins",
1311 "Fixing margins may cause strings that used to spill outside the textbox"
1312 " to instead be cut off. Are you sure?",
1313 [&](bool ret,bool)
1314 {
1315 if(ret)
1316 {
1317 set_qr(qr_OLD_STRING_EDITOR_MARGINS, 0);
1318 saved = false;
1319 }
1320 }).show();
1321 }
1322 if(get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT))
1323 {
1324 AlertDialog("Fix: Old Frame Size",
1325 "This will fix the frame size of all strings. No visual changes should occur,"
1326 " as the string width/height will be fixed, but the compat QR will also be unchecked.",
1327 [&](bool ret,bool)
1328 {
1329 if(ret)
1330 {
1331 for(auto q = 0; q < msg_count; ++q)
1332 {
1333 MsgStrings[q].w += 16;
1334 MsgStrings[q].h += 16;
1335 }
1336 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT, 0);
1337 saved = false;
1338 }
1339 }).show();
1340 }
1341 return D_O_K;
1342 }
1343
1344 enum
1345 {
1346 MENUID_FIXTOOL_OLDSTRING,
1347 };
1348
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu fixtools_menu
1349 63 {
1350
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Color Set Fix", onCSetFix },
1351
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Liquid Solidity Fix", onWaterSolidity },
1352
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Effect Square Fix", onEffectFix },
1353
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Level Palette Fix", onPalFix },
1354
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Pit and Liquid Damage Fix", onPitFix },
1355
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Old Strings Fix", onStrFix, MENUID_FIXTOOL_OLDSTRING },
1356 };
1357
1358
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu tool_menu
1359 99 {
1360
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Combo &Flags", onFlags, nullopt, MFL_EXIT_PRE_PROC },
1361
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Fix &Tools ", &fixtools_menu },
1362
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&NES Dungeon Template", onTemplate },
1363
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Apply Template to All", onReTemplate },
1364
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1365
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Preview Mode", onPreviewMode },
1366
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Drawing &Mode ", &drawing_mode_menu },
1367
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1368
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&List Combos Used", onUsedCombos },
1369
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Quest Reports ", &quest_reports_menu },
1370 };
1371
1372 int32_t onLayer3BG()
1373 {
1374 ViewLayer3BG = ViewLayer3BG ? 0 : 1;
1375 zc_set_config("zquest","layer3_bg",ViewLayer3BG);
1376 return D_O_K;
1377 }
1378 int32_t onLayer2BG()
1379 {
1380 ViewLayer2BG = ViewLayer2BG ? 0 : 1;
1381 zc_set_config("zquest","layer2_bg",ViewLayer2BG);
1382 return D_O_K;
1383 }
1384 int onGridToggle();
1385 enum
1386 {
1387 MENUID_VIEW_WALKABILITY,
1388 MENUID_VIEW_FLAGS,
1389 MENUID_VIEW_CSET,
1390 MENUID_VIEW_TYPES,
1391 MENUID_VIEW_INFO,
1392 MENUID_VIEW_SQUARES,
1393 MENUID_VIEW_FFCS,
1394 MENUID_VIEW_SCRIPTNAMES,
1395 MENUID_VIEW_GRID,
1396 MENUID_VIEW_DARKNESS,
1397 MENUID_VIEW_L2BG,
1398 MENUID_VIEW_L3BG,
1399 MENUID_VIEW_LAYERHIGHLIGHT,
1400 };
1401
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 NewMenu view_menu
1402 162 {
1403
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "View &Map...", onViewMap },
1404
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "View &Palette", onShowPal },
1405
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1406
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Walkability", onShowWalkability, MENUID_VIEW_WALKABILITY },
1407
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Flags", onShowFlags, MENUID_VIEW_FLAGS },
1408
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &CSets", onShowCSet, MENUID_VIEW_CSET },
1409
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Types", onShowCType, MENUID_VIEW_TYPES },
1410
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1411
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show Screen &Info", onToggleShowInfo, MENUID_VIEW_INFO },
1412
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Squares", onToggleShowSquares, MENUID_VIEW_SQUARES },
1413
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show FFCs", onToggleShowFFCs, MENUID_VIEW_FFCS },
1414
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show Script &Names", onToggleShowScripts, MENUID_VIEW_SCRIPTNAMES },
1415
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Grid", onGridToggle, MENUID_VIEW_GRID },
1416
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Show &Darkness", onShowDarkness, MENUID_VIEW_DARKNESS },
1417
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Layer 2 is Background", onLayer2BG, MENUID_VIEW_L2BG },
1418
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Layer 3 is Background", onLayer3BG, MENUID_VIEW_L3BG },
1419
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Highlight Current Layer", onToggleHighlightLayer, MENUID_VIEW_LAYERHIGHLIGHT },
1420 };
1421
1422 9 void set_rules(byte* newrules)
1423 {
1424 9 saved = false;
1425
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(newrules != quest_rules)
1426 memcpy(quest_rules, newrules, QR_SZ);
1427 9 unpack_qrs();
1428
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
1429 {
1430 2 combobuf[0].walk = 0xF0;
1431 2 combobuf[0].type = 0;
1432 2 combobuf[0].flag = 0;
1433 2 }
1434
1435 // For 2.50.0 and 2.50.1
1436
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(get_qr(qr_VERYFASTSCROLLING))
1437 2 set_qr(qr_FASTDNGN, 1);
1438 9 }
1439
1440 int32_t onSelectFFCombo();
1441
1442 void onScreenNotes()
1443 {
1444 edit_screen_notes(Map.CurrScr(), Map.getCurrMap(), Map.getCurrScr());
1445 }
1446
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu data_menu
1447 162 {
1448
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Screen Data", onScrData },
1449
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Freeform Combos", onSelectFFCombo },
1450
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "La&yers", onLayers },
1451
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tile Warp", onTileWarp },
1452
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Side &Warp", onSideWarp },
1453
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Secret &Combos", onSecretCombo },
1454
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Under Combo", onUnderCombo },
1455
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Doors", onDoors },
1456
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Maze Path", onPath },
1457
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1458
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Item", onItem },
1459
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Enemies", onEnemies },
1460
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Palette", onScreenPalette },
1461
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1462
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Room Data", onRoom },
1463
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Notes", onScreenNotes },
1464
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Browse Notes", browse_screen_notes },
1465 };
1466
1467
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu tunes_menu
1468 189 {
1469
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "ZC Forever", playZCForever },
1470
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Wind Fish", playTune1 },
1471
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Overworld", playTune2 },
1472
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Hyrule Castle", playTune3 },
1473
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Lost Woods", playTune4 },
1474
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Great Sea", playTune5 },
1475
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "East Hyrule", playTune6 },
1476
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Dancing Dragon", playTune7 },
1477
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Stone Tower", playTune8 },
1478
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Villages", playTune9 },
1479
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Swamp + Desert", playTune10 },
1480
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Outset Island", playTune11 },
1481
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Kakariko Village", playTune12 },
1482
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Clock Town", playTune13 },
1483
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Temple", playTune14 },
1484
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Dark World", playTune15 },
1485
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Dragon Roost", playTune16 },
1486
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Horse Race", playTune17 },
1487
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Credits", playTune18 },
1488
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Zelda's Lullaby", playTune19 },
1489 };
1490
1491 enum
1492 {
1493 MENUID_MEDIA_TUNES,
1494 MENUID_MEDIA_PLAYMUSIC,
1495 MENUID_MEDIA_CHANGETRACK,
1496 };
1497
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu media_menu
1498 45 {
1499
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Ambient Music ", &tunes_menu, MENUID_MEDIA_TUNES },
1500
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Play music", playMusic, MENUID_MEDIA_PLAYMUSIC },
1501
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Change track", changeTrack, MENUID_MEDIA_CHANGETRACK },
1502
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Stop tunes", stopMusic },
1503 };
1504
1505 enum
1506 {
1507 MENUID_ETC_VIDMODE,
1508 MENUID_ETC_FULLSCREEN,
1509 MENUID_ETC_DEBUG_CONSOLE,
1510 };
1511
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu etc_menu
1512 144 {
1513
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Help", &zq_help_menu },
1514
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&About", onAbout },
1515
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Video Mode", onZQVidMode, MENUID_ETC_VIDMODE },
1516
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Options...", onOptions },
1517
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Hotkeys...", do_zq_hotkey_dialog },
1518
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&List Hotkeys...", do_zq_list_hotkeys_dialog },
1519
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Fullscreen", onFullScreen, MENUID_ETC_FULLSCREEN },
1520
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1521
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&View Pic...", onViewPic },
1522
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Media", &media_menu },
1523
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1524
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Debug Console", toggleConsole, MENUID_ETC_DEBUG_CONSOLE },
1525
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Clear Quest Filepath", onClearQuestFilepath },
1526
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Take ZQ Snapshot", onSnapshot },
1527
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Take &Screen Snapshot", onMapscrSnapshot },
1528 };
1529
1530
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu zscript_menu
1531 63 {
1532
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Compile &ZScript...", onCompileScript },
1533
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1534
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Compiler Settings", onZScriptCompilerSettings },
1535
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Quest Script Settings", onZScriptSettings },
1536
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 {},
1537
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Import ZASM Script", onImportZASM },
1538 };
1539
1540 void set_console_state()
1541 {
1542 etc_menu.select_uid(MENUID_ETC_DEBUG_CONSOLE, console_is_open);
1543 }
1544
1545
3/16
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9 NewMenu foo_menu{{"FOO",[](){InfoDialog("PLACEHOLDER","THIS IS A PLACEHOLDER").show();}}};
1546
1547
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 TopMenu the_menu
1548 81 {
1549
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&File", &file_menu },
1550
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Quest", &quest_menu },
1551
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Edit", &edit_menu },
1552
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&View", &view_menu },
1553
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Tools", &tool_menu },
1554
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&Screen", &data_menu },
1555
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "&ZScript", &zscript_menu },
1556
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Et&C", &etc_menu },
1557 };
1558
1559 void rebuild_trans_table();
1560 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal,
1561 int32_t *px2, int32_t *py2, double *scale, bool isviewingmap, bool skipmenu = false);
1562
1563 int32_t onResetTransparency()
1564 {
1565 restore_mouse();
1566 rebuild_trans_table();
1567 jwin_alert("Notice","Translucency Table Rebuilt",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
1568
1569 refresh(rALL);
1570 return D_O_K;
1571 }
1572
1573 int32_t onFullScreen()
1574 {
1575 get_palette(RAMpal);
1576 bool windowed=is_windowed_mode()!=0;
1577 all_toggle_fullscreen(windowed);
1578
1579 gui_mouse_focus=0;
1580 gui_bg_color=jwin_pal[jcBOX];
1581 gui_fg_color=jwin_pal[jcBOXFG];
1582 MouseSprite::set(ZQM_NORMAL);
1583 zc_set_palette(RAMpal);
1584 position_mouse(zq_screen_w/2,zq_screen_h/2);
1585 set_display_switch_mode(SWITCH_BACKGROUND);
1586 set_display_switch_callback(SWITCH_OUT, switch_out);
1587 set_display_switch_callback(SWITCH_IN, switch_in);
1588 zc_set_config("zquest","fullscreen", is_windowed_mode() ? 0 : 1);
1589 return D_REDRAW;
1590 }
1591
1592 int32_t onEnter()
1593 {
1594 if(key[KEY_ALT]||key[KEY_ALTGR])
1595 {
1596 return onFullScreen();
1597 }
1598
1599 return D_O_K;
1600 }
1601
1602 //PROC, x, y, w, h, fg, bg, key, flags, d1, d2, *dp, *dp2, *dp3
1603
1604 //*text, (*proc), *child, flags, *dp
1605
1606 void run_zq_frame();
1607 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c);
1608
1609
1610 /*int32_t onY()
1611 {
1612 return D_O_K;
1613 }*/
1614
1615 int32_t onToggleGrid(bool color)
1616 {
1617 if(color)
1618 {
1619 GridColor=(GridColor+8)%16;
1620 zc_set_config("zquest", "grid_color", GridColor);
1621 }
1622 else
1623 {
1624 ShowGrid=!ShowGrid;
1625 zc_set_config("zquest","show_grid",ShowGrid);
1626 }
1627
1628 return D_O_K;
1629 }
1630 int onGridToggle()
1631 {
1632 return onToggleGrid(CHECK_CTRL_CMD);
1633 }
1634
1635 int32_t onToggleShowScripts()
1636 {
1637 ShowFFScripts=!ShowFFScripts;
1638 zc_set_config("zquest","showffscripts",ShowFFScripts);
1639 return D_O_K;
1640 }
1641
1642 int32_t onToggleShowFFCs()
1643 {
1644 ShowFFCs=!ShowFFCs;
1645 zc_set_config("zquest","showffcs",ShowFFCs);
1646 return D_O_K;
1647 }
1648
1649 int32_t onToggleShowSquares()
1650 {
1651 ShowSquares=!ShowSquares;
1652 zc_set_config("zquest","showsquares",ShowSquares);
1653 return D_O_K;
1654 }
1655
1656 int32_t onToggleShowInfo()
1657 {
1658 ShowInfo=!ShowInfo;
1659 zc_set_config("zquest","showinfo",ShowInfo);
1660 return D_O_K;
1661 }
1662
1663 int32_t onToggleHighlightLayer()
1664 {
1665 ActiveLayerHighlight = ActiveLayerHighlight ? 0 : 1;
1666 zc_set_config("zquest","hl_active_lyr",ActiveLayerHighlight);
1667 return D_O_K;
1668 }
1669
1670 int onKeySlash()
1671 {
1672 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1673 {
1674 onAbout();
1675 }
1676 return D_O_K;
1677 }
1678
1679 int onAKey()
1680 {
1681 if(prv_mode)
1682 Map.set_prvadvance(1);
1683 return D_O_K;
1684 }
1685
1686 int onReloadPreview()
1687 {
1688 if(prv_mode)
1689 {
1690 Map.set_prvscr(Map.get_prv_map(), Map.get_prv_scr());
1691 Map.set_prvcmb(0);
1692 }
1693 return D_O_K;
1694 }
1695 int onSecretsPreview()
1696 {
1697 if(prv_mode)
1698 {
1699 Map.prv_secrets(false);
1700 refresh(rALL);
1701 }
1702 return D_O_K;
1703 }
1704
1705 int onSKey()
1706 {
1707 if(CHECK_CTRL_CMD)
1708 {
1709 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1710 {
1711 onSaveAs();
1712 }
1713 else
1714 {
1715 if(!saved)
1716 onSave();
1717 }
1718 }
1719 else if(prv_mode)
1720 {
1721 Map.prv_secrets(false);
1722 refresh(rALL);
1723 }
1724 else onStrings();
1725 return D_O_K;
1726 }
1727 int onSetNewLayer(int newlayer)
1728 {
1729 CurrentLayer = newlayer;
1730 refresh(rALL);
1731 return D_O_K;
1732 }
1733 void lpal_dsa()
1734 {
1735 info_dsa("Level Palette Shortcuts",
1736 "You currently have level palette shortcuts disabled."
1737 " These can be re-enabled in 'Etc->Options', on the toggle 'Disable Level Palette Shortcuts'.",
1738 "dsa_lpal");
1739 }
1740 int onScreenLPal(int lpal)
1741 {
1742 if(DisableLPalShortcuts)
1743 {
1744 lpal_dsa();
1745 return D_O_K;
1746 }
1747 saved=false;
1748 Map.setcolor(lpal);
1749 refresh(rSCRMAP);
1750 return D_O_K;
1751 }
1752
1753 int32_t onPressEsc()
1754 {
1755 if(zoomed_minimap)
1756 mmap_set_zoom(false);
1757 else return onExit();
1758 return D_O_K;
1759 }
1760
1761 static DIALOG dialogs[] =
1762 {
1763 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
1764 { d_nbmenu_proc, 0, 0, 0, 13, 0, 0, 0, D_USER, 0, 0, (void *) &the_menu, NULL, NULL },
1765 { d_zq_hotkey_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1766
1767 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
1768 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESC, 0, (void *) onPressEsc, NULL, NULL },
1769 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, (void *) onUsedCombos, NULL, NULL },
1770 { d_vsync_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1771 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1772 };
1773
1774
1775 int32_t onDecColour()
1776 {
1777 if ( CHECK_CTRL_CMD )
1778 {
1779 return onDecScrPal16();
1780 }
1781
1782 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1783 {
1784 return onDecScrPal();
1785 }
1786
1787 else
1788 {
1789 return onDecreaseCSet();
1790 }
1791 }
1792
1793 int32_t onIncColour()
1794 {
1795
1796 if ( CHECK_CTRL_CMD )
1797 {
1798 return onIncScrPal16();
1799 }
1800
1801 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1802 {
1803 return onIncScrPal();
1804 }
1805
1806 else
1807 {
1808 return onIncreaseCSet();
1809 }
1810 }
1811
1812 static DIALOG getnum_dlg[] =
1813 {
1814 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1815 9 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
1816 9 { jwin_rtext_proc, 114, 104+4, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) "Value:", NULL, NULL },
1817 9 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
1818 9 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
1819 9 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1820 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1821 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1822 };
1823
1824 int32_t getnumber(const char *prompt,int32_t initialval)
1825 {
1826 cancelgetnum=true;
1827 char buf[20];
1828 sprintf(buf,"%d",initialval);
1829 getnum_dlg[0].dp=(void *)prompt;
1830 getnum_dlg[0].dp2=get_zc_font(font_lfont);
1831 getnum_dlg[2].dp=(void *)buf;
1832
1833 large_dialog(getnum_dlg);
1834
1835 int32_t ret=do_zqdialog(getnum_dlg,2);
1836
1837 if(ret!=0&&ret!=4)
1838 {
1839 cancelgetnum=false;
1840 }
1841
1842 if(ret==3)
1843 return atoi(buf);
1844
1845 return initialval;
1846 }
1847
1848 static DIALOG save_tiles_dlg[] =
1849 {
1850 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1851
1852
1853 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Tile Pack", NULL, NULL },
1854 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1855 //for future tabs
1856 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1857 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1858 //4
1859 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
1860 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1861 //6
1862 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1863 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1864 //8
1865 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
1866 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1867 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1868 };
1869
1870
1871 void savesometiles(const char *prompt,int32_t initialval)
1872 {
1873
1874 char firsttile[8], tilecount[8];
1875 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1876 sprintf(firsttile,"%d",0);
1877 sprintf(tilecount,"%d",1);
1878 //int32_t ret;
1879
1880
1881
1882 save_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1883
1884 sprintf(firsttile,"%d",0);
1885 sprintf(tilecount,"%d",1);
1886
1887 save_tiles_dlg[5].dp = firsttile;
1888 save_tiles_dlg[7].dp = tilecount;
1889
1890 large_dialog(save_tiles_dlg);
1891
1892 int32_t ret = do_zqdialog(save_tiles_dlg,-1);
1893 jwin_center_dialog(save_tiles_dlg);
1894
1895 if(ret == 8)
1896 {
1897 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
1898 the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
1899 if(prompt_for_new_file_compat("Save ZTILE(.ztile)", "ztile", NULL,datapath,false))
1900 {
1901 char name[PATH_MAX];
1902 extract_name(temppath,name,FILENAMEALL);
1903 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
1904 if(f)
1905 {
1906 writetilefile(f,first_tile_id,the_tile_count);
1907 pack_fclose(f);
1908 char tmpbuf[PATH_MAX+20]={0};
1909 sprintf(tmpbuf,"Saved %s",name);
1910 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1911 }
1912 }
1913 }
1914 }
1915
1916 static DIALOG read_tiles_dlg[] =
1917 {
1918 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1919
1920
1921 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Tilepack To:", NULL, NULL },
1922 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1923 //for future tabs
1924 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1925 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1926 //4
1927 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
1928 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1929 //6
1930 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1931 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1932 //8
1933 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
1934 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1935 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1936 };
1937
1938
1939 void writesometiles_to(const char *prompt,int32_t initialval)
1940 {
1941
1942 char firsttile[8];;
1943 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1944 sprintf(firsttile,"%d",0);
1945 //int32_t ret;
1946
1947
1948
1949 read_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1950
1951 sprintf(firsttile,"%d",0);
1952 //sprintf(tilecount,"%d",1);
1953
1954 read_tiles_dlg[5].dp = firsttile;
1955
1956 large_dialog(read_tiles_dlg);
1957
1958 int32_t ret = do_zqdialog(read_tiles_dlg,-1);
1959 jwin_center_dialog(read_tiles_dlg);
1960
1961 if(ret == 8)
1962 {
1963 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
1964 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
1965 if(prompt_for_existing_file_compat("Load ZTILE(.ztile)", "ztile", NULL,datapath,false))
1966 {
1967
1968 char name[256];
1969 extract_name(temppath,name,FILENAMEALL);
1970 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
1971 if(f)
1972 {
1973
1974 if (!readtilefile_to_location(f,first_tile_id))
1975 {
1976 al_trace("Could not read from .ztile packfile %s\n", name);
1977 jwin_alert("ZTILE File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1978 }
1979 else
1980 {
1981 jwin_alert("ZTILE File: Success!","Loaded the source tiles to your tile sheets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1982 }
1983 pack_fclose(f);
1984 }
1985 }
1986 }
1987 }
1988
1989
1990 static DIALOG save_combofiles_dlg[] =
1991 {
1992 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1993
1994
1995 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Pack", NULL, NULL },
1996 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1997 //for future tabs
1998 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1999 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2000 //4
2001 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2002 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2003 //6
2004 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2005 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2006 //8
2007 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2008 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2009 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2010 };
2011
2012
2013 void savesomecombos(const char *prompt,int32_t initialval)
2014 {
2015
2016 char firsttile[8], tilecount[8];
2017 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2018 sprintf(firsttile,"%d",0);
2019 sprintf(tilecount,"%d",1);
2020 //int32_t ret;
2021
2022
2023
2024 save_combofiles_dlg[0].dp2 = get_zc_font(font_lfont);
2025
2026 sprintf(firsttile,"%d",0);
2027 sprintf(tilecount,"%d",1);
2028
2029 save_combofiles_dlg[5].dp = firsttile;
2030 save_combofiles_dlg[7].dp = tilecount;
2031
2032 large_dialog(save_combofiles_dlg);
2033
2034 int32_t ret = do_zqdialog(save_combofiles_dlg,-1);
2035 jwin_center_dialog(save_combofiles_dlg);
2036
2037 if(ret == 8)
2038 {
2039 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2040 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOS-1)-first_tile_id);
2041 if(prompt_for_new_file_compat("Save ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2042 {
2043 char name[PATH_MAX];
2044 extract_name(temppath,name,FILENAMEALL);
2045 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2046 if(f)
2047 {
2048 writecombofile(f,first_tile_id,the_tile_count);
2049 pack_fclose(f);
2050 char tmpbuf[PATH_MAX+20]={0};
2051 sprintf(tmpbuf,"Saved %s",name);
2052 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2053 }
2054 }
2055 }
2056 }
2057
2058
2059 static DIALOG load_comboset_dlg[] =
2060 {
2061 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2062
2063
2064 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Set (Range)", NULL, NULL },
2065 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2066 //for future tabs
2067 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2068 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2069 //4
2070 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2071 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2072 //6
2073 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2074 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2075 //8
2076 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2077 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2078 { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2079
2080 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2081 };
2082
2083 void writesomecombos(const char *prompt,int32_t initialval)
2084 {
2085
2086 char firsttile[8];
2087 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2088 sprintf(firsttile,"%d",0);
2089 //int32_t ret;
2090
2091
2092
2093 load_comboset_dlg[0].dp2 = get_zc_font(font_lfont);
2094
2095 sprintf(firsttile,"%d",0);
2096 //sprintf(tilecount,"%d",1);
2097
2098 load_comboset_dlg[5].dp = firsttile;
2099
2100 byte nooverwrite = 0;
2101
2102
2103 large_dialog(load_comboset_dlg);
2104
2105 int32_t ret = do_zqdialog(load_comboset_dlg,-1);
2106 jwin_center_dialog(load_comboset_dlg);
2107
2108 if(ret == 8)
2109 {
2110 if (load_comboset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2111
2112 al_trace("Nooverwrite is: %d\n", nooverwrite);
2113 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2114 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2115 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2116 {
2117 char name[256];
2118 extract_name(temppath,name,FILENAMEALL);
2119 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2120 if(f)
2121 {
2122
2123 if (!readcombofile(f,first_tile_id,nooverwrite))
2124 {
2125 al_trace("Could not read from .zcombo packfile %s\n", name);
2126 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2127 }
2128 else
2129 {
2130 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2131 saved=false;
2132 }
2133 pack_fclose(f);
2134 }
2135
2136 }
2137 }
2138 }
2139
2140 static DIALOG load_combopack_dlg[] =
2141 {
2142 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2143
2144
2145 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import Full Combo Package 1:1", NULL, NULL },
2146 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2147 //for future tabs
2148 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2149 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2150 //4
2151 { d_dummy_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2152 { d_dummy_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2153 //6
2154 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2155 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2156 //8
2157 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2158 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2159 { jwin_check_proc, 10, 42, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2160
2161 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2162 };
2163
2164 void loadcombopack(const char *prompt,int32_t initialval)
2165 {
2166
2167 char firsttile[8];
2168 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2169 sprintf(firsttile,"%d",0);
2170 //int32_t ret;
2171
2172
2173
2174 load_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2175
2176 sprintf(firsttile,"%d",0);
2177 //sprintf(tilecount,"%d",1);
2178
2179 load_combopack_dlg[5].dp = firsttile;
2180
2181 byte nooverwrite = 0;
2182
2183
2184 large_dialog(load_combopack_dlg);
2185
2186 int32_t ret = do_zqdialog(load_combopack_dlg,-1);
2187 jwin_center_dialog(load_combopack_dlg);
2188
2189 if(ret == 8)
2190 {
2191 if (load_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2192
2193 al_trace("Nooverwrite is: %d\n", nooverwrite);
2194 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2195 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2196 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2197 {
2198 char name[256];
2199 extract_name(temppath,name,FILENAMEALL);
2200 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2201 if(f)
2202 {
2203 //need dialogue here
2204 if (!readcombofile(f,0,nooverwrite))
2205 {
2206 al_trace("Could not read from .zcombo packfile %s\n", name);
2207 jwin_alert("ZCOMBO File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2208 }
2209 else
2210 {
2211 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2212 saved=false;
2213 }
2214 }
2215
2216 pack_fclose(f);
2217 }
2218 }
2219 }
2220
2221
2222 static DIALOG read_combopack_dlg[] =
2223 {
2224 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2225
2226
2227 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combos (Specific Dest)", NULL, NULL },
2228 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2229 //for future tabs
2230 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2231 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2232 //4
2233 { jwin_text_proc, 10, 24, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2234 { jwin_edit_proc, 55, 22, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2235 //6
2236 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2237 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2238 //8
2239 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2240 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2241 //10
2242 { jwin_check_proc, 10, 58, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2243 //11
2244 { jwin_text_proc, 10, 42, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Skip:", NULL, NULL },
2245 //12
2246 { jwin_edit_proc, 55, 40, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2247
2248 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2249 };
2250
2251
2252
2253 void writesomecombos_to(const char *prompt,int32_t initialval)
2254 {
2255
2256 char firsttile[8];
2257 char skiptile[8];
2258 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2259 sprintf(firsttile,"%d",0);
2260 //int32_t ret;
2261
2262
2263
2264 read_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2265
2266 sprintf(skiptile,"%d",0);
2267 //sprintf(tilecount,"%d",1);
2268
2269 read_combopack_dlg[5].dp = firsttile;
2270
2271 byte nooverwrite = 0;
2272 int32_t skipover = 0;
2273
2274 sprintf(skiptile,"%d",0);
2275 //sprintf(tilecount,"%d",1);
2276
2277 read_combopack_dlg[12].dp = skiptile;
2278
2279 large_dialog(read_combopack_dlg);
2280
2281 int32_t ret = do_zqdialog(read_combopack_dlg,-1);
2282 jwin_center_dialog(read_combopack_dlg);
2283
2284 if(ret == 8)
2285 {
2286 if (read_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2287
2288 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2289 skipover = vbound(atoi(skiptile), 0, (MAXCOMBOS-1));
2290 al_trace("skipover is: %d\n", skipover);
2291 //skipover = vbound(skipover, 0, (MAXCOMBOS-1-skipover));
2292 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2293 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2294 {
2295 char name[256];
2296 extract_name(temppath,name,FILENAMEALL);
2297 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2298 if(f)
2299 {
2300
2301 if (!readcombofile_to_location(f,first_tile_id,nooverwrite, skipover))
2302 {
2303 al_trace("Could not read from .zcombo packfile %s\n", name);
2304 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2305 }
2306 else
2307 {
2308 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2309 saved=false;
2310 }
2311 pack_fclose(f);
2312 }
2313
2314 }
2315 }
2316 }
2317
2318
2319
2320 static DIALOG save_dmaps_dlg[] =
2321 {
2322 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2323
2324
2325 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save DMaps (.zdmap)", NULL, NULL },
2326 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2327 //for future tabs
2328 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2329 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2330 //4
2331 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2332 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2333 //6
2334 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Last", NULL, NULL },
2335 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2336 //8
2337 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2338 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2339 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2340 };
2341
2342
2343 void savesomedmaps(const char *prompt,int32_t initialval)
2344 {
2345
2346 char firstdmap[8], lastdmap[8];
2347 int32_t first_dmap_id = 0; int32_t last_dmap_id = 0;
2348 sprintf(firstdmap,"%d",0);
2349 sprintf(lastdmap,"%d",1);
2350 //int32_t ret;
2351
2352
2353
2354 save_dmaps_dlg[0].dp2 = get_zc_font(font_lfont);
2355
2356 sprintf(firstdmap,"%d",0);
2357 sprintf(lastdmap,"%d",0);
2358
2359 save_dmaps_dlg[5].dp = firstdmap;
2360 save_dmaps_dlg[7].dp = lastdmap;
2361
2362 large_dialog(save_dmaps_dlg);
2363
2364 int32_t ret = do_zqdialog(save_dmaps_dlg,-1);
2365 jwin_center_dialog(save_dmaps_dlg);
2366
2367 if(ret == 8)
2368 {
2369 first_dmap_id = vbound(atoi(firstdmap), 0, MAXDMAPS-1);
2370 last_dmap_id = vbound(atoi(lastdmap), 0, MAXDMAPS-1);
2371
2372 if ( last_dmap_id < first_dmap_id )
2373 {
2374 int32_t swap = last_dmap_id;
2375 last_dmap_id = first_dmap_id;
2376 first_dmap_id = swap;
2377 }
2378 if(!prompt_for_new_file_compat("Export DMaps (.zdmap)","zdmap",NULL,datapath,false))
2379
2380
2381 saved=false;
2382
2383 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2384 if(f)
2385 {
2386 if(!writesomedmaps(f,first_dmap_id,last_dmap_id,MAXDMAPS))
2387 {
2388 char buf[PATH_MAX+20],name[PATH_MAX];
2389 extract_name(temppath,name,FILENAMEALL);
2390 sprintf(buf,"Unable to load %s",name);
2391 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2392 }
2393 else
2394 {
2395 char name[PATH_MAX];
2396 extract_name(temppath,name,FILENAMEALL);
2397 char tmpbuf[PATH_MAX+20]={0};
2398 sprintf(tmpbuf,"Saved %s",name);
2399 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2400 }
2401 }
2402 pack_fclose(f);
2403 }
2404 }
2405
2406 static DIALOG save_comboaliasfiles_dlg[] =
2407 {
2408 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2409
2410
2411 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Alias Pack", NULL, NULL },
2412 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2413 //for future tabs
2414 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2415 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2416 //4
2417 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2418 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2419 //6
2420 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2421 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2422 //8
2423 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2424 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2425 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2426 };
2427
2428
2429 void savesomecomboaliases(const char *prompt,int32_t initialval)
2430 {
2431
2432 char firsttile[8], tilecount[8];
2433 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2434 sprintf(firsttile,"%d",0);
2435 sprintf(tilecount,"%d",1);
2436 //int32_t ret;
2437
2438
2439
2440 save_comboaliasfiles_dlg[0].dp2 = get_zc_font(font_lfont);
2441
2442 sprintf(firsttile,"%d",0);
2443 sprintf(tilecount,"%d",1);
2444
2445 save_comboaliasfiles_dlg[5].dp = firsttile;
2446 save_comboaliasfiles_dlg[7].dp = tilecount;
2447
2448 large_dialog(save_comboaliasfiles_dlg);
2449
2450 int32_t ret = do_zqdialog(save_comboaliasfiles_dlg,-1);
2451 jwin_center_dialog(save_comboaliasfiles_dlg);
2452
2453 if(ret == 8)
2454 {
2455 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2456 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOALIASES-1)-first_tile_id);
2457 if(prompt_for_new_file_compat("Save ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2458 {
2459 char name[PATH_MAX];
2460 extract_name(temppath,name,FILENAMEALL);
2461 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2462 if(f)
2463 {
2464 writecomboaliasfile(f,first_tile_id,the_tile_count);
2465 pack_fclose(f);
2466 char tmpbuf[PATH_MAX+20]={0};
2467 sprintf(tmpbuf,"Saved %s",name);
2468 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2469 }
2470 }
2471 }
2472 }
2473
2474
2475 static DIALOG read_comboaliaspack_dlg[] =
2476 {
2477 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2478
2479
2480 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combo Pack To:", NULL, NULL },
2481 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2482 //for future tabs
2483 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2484 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2485 //4
2486 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2487 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2488 //6
2489 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2490 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2491 //8
2492 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2493 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2494 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2495 };
2496
2497
2498 void writesomecomboaliases_to(const char *prompt,int32_t initialval)
2499 {
2500
2501 char firsttile[8];;
2502 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2503 sprintf(firsttile,"%d",0);
2504 //int32_t ret;
2505
2506
2507
2508 read_comboaliaspack_dlg[0].dp2 = get_zc_font(font_lfont);
2509
2510 sprintf(firsttile,"%d",0);
2511 //sprintf(tilecount,"%d",1);
2512
2513 read_comboaliaspack_dlg[5].dp = firsttile;
2514
2515 large_dialog(read_comboaliaspack_dlg);
2516
2517 int32_t ret = do_zqdialog(read_comboaliaspack_dlg,-1);
2518 jwin_center_dialog(read_comboaliaspack_dlg);
2519
2520 if(ret == 8)
2521 {
2522 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2523 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2524 if(prompt_for_existing_file_compat("Load ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2525 {
2526 char name[256];
2527 extract_name(temppath,name,FILENAMEALL);
2528 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2529 if(f)
2530 {
2531
2532 if (!readcomboaliasfile_to_location(f,first_tile_id))
2533 {
2534 al_trace("Could not read from .zcombo packfile %s\n", name);
2535 jwin_alert("ZALIAS File: Error","Could not load the specified combo aliases.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2536 }
2537 else
2538 {
2539 jwin_alert("ZALIAS File: Success!","Loaded the source combos to your combo alias table!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2540 saved=false;
2541 }
2542 pack_fclose(f);
2543 }
2544 }
2545 }
2546 }
2547
2548
2549
2550
2551 //Doorsets
2552
2553 static DIALOG save_doorset_dlg[] =
2554 {
2555 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2556 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Doorset", NULL, NULL },
2557 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2558 //for future tabs
2559 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2560 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2561 //4
2562 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2563 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2564 //6
2565 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2566 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2567 //8
2568 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2569 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2570 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2571 };
2572
2573
2574 void do_exportdoorset(const char *prompt,int32_t initialval)
2575 {
2576 char firstdoor[8], doorct[8];
2577 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2578 sprintf(firstdoor,"%d",0);
2579 sprintf(doorct,"%d",1);
2580 //int32_t ret;
2581 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2582
2583 sprintf(firstdoor,"%d",0);
2584 sprintf(doorct,"%d",1);
2585
2586 save_doorset_dlg[5].dp = firstdoor;
2587 save_doorset_dlg[7].dp = doorct;
2588
2589 large_dialog(save_doorset_dlg);
2590
2591 int32_t ret = do_zqdialog(save_doorset_dlg,-1);
2592 jwin_center_dialog(save_doorset_dlg);
2593
2594 if(ret == 8) //OK
2595 {
2596 /* sanity bounds
2597 first_doorset_id = vbound(atoi(firstdoor), 0, (MAXCOMBOS-1));
2598 the_doorset_count = vbound(atoi(doorct), 1, (MAXCOMBOS-1)-first_doorset_id);
2599 */
2600 if(prompt_for_new_file_compat("Save ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2601 {
2602 char name[256];
2603 extract_name(temppath,name,FILENAMEALL);
2604 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2605 if(f)
2606 {
2607 writezdoorsets(f,first_doorset_id,the_doorset_count);
2608 pack_fclose(f);
2609 char tmpbuf[512]={0};
2610 sprintf(tmpbuf,"Saved %s",name);
2611 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2612 }
2613 }
2614 }
2615 }
2616
2617 static DIALOG load_doorset_dlg[] =
2618 {
2619 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2620 { jwin_win_proc, 0, 0, 120, 124, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Door Set (Range)", NULL, NULL },
2621 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2622 //for future tabs
2623 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2624 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2625 //4
2626 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2627 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2628 //6
2629 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2630 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2631 //8
2632 { jwin_button_proc, 15, 92, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2633 { jwin_button_proc, 69, 92, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2634 //10
2635 { jwin_text_proc, 10, 64, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Dest", NULL, NULL },
2636 { jwin_edit_proc, 55, 63, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2637 //8
2638
2639 // { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2640
2641 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2642 };
2643
2644 void do_importdoorset(const char *prompt,int32_t initialval)
2645 {
2646
2647 char firstdoor[8], doorct[8], destid[8];
2648 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2649 int32_t the_dest_id = 0;
2650 sprintf(firstdoor,"%d",0);
2651 sprintf(doorct,"%d",1);
2652 sprintf(destid,"%d",0);
2653 //int32_t ret;
2654
2655 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2656
2657 load_doorset_dlg[5].dp = firstdoor;
2658 load_doorset_dlg[7].dp = doorct;
2659 load_doorset_dlg[11].dp = destid;
2660
2661 byte nooverwrite = 0;
2662
2663 large_dialog(load_doorset_dlg);
2664
2665 int32_t ret = do_zqdialog(load_doorset_dlg,-1);
2666 jwin_center_dialog(load_doorset_dlg);
2667
2668 if(ret == 8) //OK
2669 {
2670 //if (load_doorset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2671
2672 //sanity bound
2673 first_doorset_id = vbound(atoi(firstdoor), 0, door_combo_set_count);
2674 the_doorset_count = vbound(atoi(doorct), 1, door_combo_set_count);
2675 the_dest_id = vbound(atoi(destid), 0, door_combo_set_count);
2676 if(prompt_for_existing_file_compat("Load ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2677 {
2678 char name[256];
2679 extract_name(temppath,name,FILENAMEALL);
2680 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2681 if(f)
2682 {
2683 int32_t ret = readzdoorsets(f,first_doorset_id,the_doorset_count, the_dest_id);
2684
2685 if (!ret)
2686 {
2687 al_trace("Could not read from .zdoors packfile %s\n", name);
2688 jwin_alert("ZDOORS File: Error","Could not load the specified doorsets.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2689 }
2690 else if ( ret == 1 )
2691 {
2692 jwin_alert("ZDOORS File: Success!","Loaded the source doorsets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2693 saved=false;
2694 }
2695 else if ( ret == 2 )
2696 {
2697 jwin_alert("ZDOORS File: Issue:","Targets exceed doorset count!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2698 saved=false;
2699 }
2700 pack_fclose(f);
2701 }
2702 }
2703 }
2704 }
2705
2706 int32_t gettilepagenumber(const char *prompt, int32_t initialval)
2707 {
2708 char buf[20];
2709 sprintf(buf,"%d",initialval);
2710 getnum_dlg[0].dp=(void *)prompt;
2711 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2712 getnum_dlg[2].dp=buf;
2713
2714 large_dialog(getnum_dlg);
2715
2716 int32_t ret = do_zqdialog(getnum_dlg,2);
2717
2718 if(ret==3)
2719 return atoi(buf);
2720
2721 return -1;
2722 }
2723
2724 int32_t gethexnumber(const char *prompt,int32_t initialval)
2725 {
2726 cancelgetnum=true;
2727 char buf[20];
2728 sprintf(buf,"%X",initialval);
2729 getnum_dlg[0].dp=(void *)prompt;
2730 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2731 getnum_dlg[2].dp=(void *)buf;
2732
2733 large_dialog(getnum_dlg);
2734
2735 int32_t ret=do_zqdialog(getnum_dlg,2);
2736
2737 if(ret!=0&&ret!=4)
2738 {
2739 cancelgetnum=false;
2740 }
2741
2742 if(ret==3)
2743 return zc_xtoi(buf);
2744
2745 return initialval;
2746 }
2747
2748 void update_combo_cycling()
2749 {
2750 Map.update_combo_cycling();
2751 }
2752
2753 void update_freeform_combos()
2754 {
2755 Map.update_freeform_combos();
2756 }
2757
2758 bool layers_valid(mapscr *tempscr)
2759 {
2760 for(int32_t i=0; i<6; i++)
2761 {
2762 if(tempscr->layermap[i]>map_count)
2763 {
2764 return false;
2765 }
2766 }
2767
2768 return true;
2769 }
2770
2771 void fix_layers(mapscr *tempscr, bool showwarning)
2772 {
2773 char buf[80]="layers have been changed: ";
2774
2775 for(int32_t i=0; i<6; i++)
2776 {
2777 if(tempscr->layermap[i]>map_count)
2778 {
2779 strcat(buf, "%d ");
2780 sprintf(buf, buf, i+1);
2781 tempscr->layermap[i]=0;
2782 }
2783 }
2784
2785 if(showwarning)
2786 {
2787 jwin_alert("Invalid layers detected",
2788 "One or more layers on this screen used",
2789 "maps that do not exist. The settings of these",
2790 buf, "O&K", NULL, 'o', 0, get_zc_font(font_lfont));
2791 }
2792 }
2793
2794 extern const char *colorlist(int32_t index, int32_t *list_size);
2795
2796 static char autobackup_str_buf[32];
2797 const char *autobackuplist(int32_t index, int32_t *list_size)
2798 {
2799 if(index>=0)
2800 {
2801 bound(index,0,10);
2802
2803 if(index==0)
2804 {
2805 sprintf(autobackup_str_buf,"Disabled");
2806 }
2807 else
2808 {
2809 sprintf(autobackup_str_buf,"%2d",index);
2810 }
2811
2812 return autobackup_str_buf;
2813 }
2814
2815 *list_size=11;
2816 return NULL;
2817 }
2818
2819 static char autosave_str_buf[32];
2820 const char *autosavelist(int32_t index, int32_t *list_size)
2821 {
2822 if(index>=0)
2823 {
2824 bound(index,0,10);
2825
2826 if(index==0)
2827 {
2828 sprintf(autosave_str_buf,"Disabled");
2829 }
2830 else
2831 {
2832 sprintf(autosave_str_buf,"%2d Minute%c",index,index>1?'s':0);
2833 }
2834
2835 return autosave_str_buf;
2836 }
2837
2838 *list_size=11;
2839 return NULL;
2840 }
2841
2842 const char *autosavelist2(int32_t index, int32_t *list_size)
2843 {
2844 if(index>=0)
2845 {
2846 bound(index,0,9);
2847 sprintf(autosave_str_buf,"%2d",index+1);
2848 return autosave_str_buf;
2849 }
2850
2851 *list_size=10;
2852 return NULL;
2853 }
2854
2855
2856 static int32_t options_1_list[] =
2857 {
2858 // dialog control number
2859 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1
2860 };
2861
2862 static int32_t options_2_list[] =
2863 {
2864 // dialog control number
2865 50, 51, -1
2866 };
2867
2868 static int32_t options_3_list[] =
2869 {
2870 // dialog control number
2871 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1
2872 };
2873 static int32_t options_4_list[] =
2874 {
2875 57, 58, 59, 60,
2876 -1
2877 };
2878
2879 static TABPANEL options_tabs[] =
2880 {
2881 // (text)
2882 { (char *)" 1 ", D_SELECTED, options_1_list, 0, NULL },
2883 { (char *)" 2 ", 0, options_2_list, 0, NULL },
2884 { (char *)" 3 ", 0, options_3_list, 0, NULL },
2885 { (char *)" 4 ", 0, options_4_list, 0, NULL },
2886 { NULL, 0, NULL, 0, NULL }
2887 };
2888
2889 9 static ListData autobackup_list(autobackuplist, &font);
2890 9 static ListData autosave_list(autosavelist, &font);
2891 9 static ListData autosave_list2(autosavelist2, &font);
2892 9 static ListData color_list(colorlist, &font);
2893 9 static ListData snapshotformat_list(snapshotformatlist, &font);
2894 void init_ffpos();
2895
2896 void call_options_dlg();
2897 int32_t onOptions()
2898 {
2899 call_options_dlg();
2900 return D_O_K;
2901 }
2902
2903 const char *dm_names[dm_max]=
2904 {
2905 "Normal",
2906 "Relational",
2907 "Dungeon",
2908 "Alias",
2909 "Pool",
2910 "Auto"
2911 };
2912
2913 byte relational_tile_grid[11+(rtgyo*2)][16+(rtgxo*2)];
2914
2915 void fix_drawing_mode_menu()
2916 {
2917 drawing_mode_menu.select_only_uid(draw_mode);
2918 }
2919
2920 void reset_relational_tile_grid()
2921 {
2922 memset(relational_tile_grid,(draw_mode==dm_relational?1:0),(11+(rtgyo*2))*(16+(rtgxo*2)));
2923 }
2924
2925 int32_t onDrawingMode()
2926 {
2927 draw_mode=(draw_mode+1)%dm_max;
2928 if (draw_mode == dm_relational)
2929 draw_mode += 2;
2930 reset_relational_tile_grid();
2931 fix_drawing_mode_menu();
2932 restore_mouse();
2933 return D_O_K;
2934 }
2935
2936 int32_t onDrawingModeNormal()
2937 {
2938 draw_mode=dm_normal;
2939 reset_relational_tile_grid();
2940 fix_drawing_mode_menu();
2941 restore_mouse();
2942 return D_O_K;
2943 }
2944
2945 int32_t onDrawingModeRelational()
2946 {
2947 if(draw_mode==dm_relational)
2948 {
2949 return onDrawingModeNormal();
2950 }
2951
2952 draw_mode=dm_relational;
2953 reset_relational_tile_grid();
2954 fix_drawing_mode_menu();
2955 restore_mouse();
2956 return D_O_K;
2957 }
2958
2959 int32_t onDrawingModeDungeon()
2960 {
2961 if(draw_mode==dm_dungeon)
2962 {
2963 return onDrawingModeNormal();
2964 }
2965
2966 draw_mode=dm_dungeon;
2967 reset_relational_tile_grid();
2968 fix_drawing_mode_menu();
2969 restore_mouse();
2970 return D_O_K;
2971 }
2972
2973 int32_t onDrawingModeAlias()
2974 {
2975 if(draw_mode==dm_alias)
2976 {
2977 return onDrawingModeNormal();
2978 }
2979
2980 draw_mode=dm_alias;
2981 alias_cset_mod=0;
2982 reset_relational_tile_grid();
2983 fix_drawing_mode_menu();
2984 restore_mouse();
2985 return D_O_K;
2986 }
2987
2988 int32_t onDrawingModePool()
2989 {
2990 if(draw_mode==dm_cpool)
2991 {
2992 return onDrawingModeNormal();
2993 }
2994
2995 draw_mode=dm_cpool;
2996 reset_relational_tile_grid();
2997 fix_drawing_mode_menu();
2998 restore_mouse();
2999 return D_O_K;
3000 }
3001
3002 int32_t onDrawingModeAuto()
3003 {
3004 if (draw_mode == dm_auto)
3005 {
3006 return onDrawingModeNormal();
3007 }
3008
3009 draw_mode = dm_auto;
3010 reset_relational_tile_grid();
3011 fix_drawing_mode_menu();
3012 restore_mouse();
3013 return D_O_K;
3014 }
3015
3016 int32_t onReTemplate()
3017 {
3018 if(jwin_alert("Confirm Overwrite","Apply NES Dungeon template to","all screens on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
3019 {
3020 Map.TemplateAll();
3021 refresh(rALL);
3022 }
3023
3024 return D_O_K;
3025 }
3026
3027 int32_t onUndo()
3028 {
3029 Map.UndoCommand();
3030 refresh(rALL);
3031 return D_O_K;
3032 }
3033
3034 int32_t onRedo()
3035 {
3036 Map.RedoCommand();
3037 refresh(rALL);
3038 return D_O_K;
3039 }
3040
3041 int32_t onCopy()
3042 {
3043 if(prv_mode)
3044 {
3045 Map.set_prvcmb(Map.get_prvcmb()==0?1:0);
3046
3047 init_ffpos();
3048
3049 return D_O_K;
3050 }
3051
3052 Map.Copy();
3053 return D_O_K;
3054 }
3055
3056 int32_t onPaste()
3057 {
3058 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
3059 {
3060 if(CHECK_CTRL_CMD)
3061 return onPasteAllToAll();
3062 else return onPasteAll();
3063 }
3064 else if(CHECK_CTRL_CMD)
3065 return onPasteToAll();
3066 else
3067 {
3068 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartial);
3069 }
3070 return D_O_K;
3071 }
3072
3073 int32_t onPasteAll()
3074 {
3075 Map.DoPasteScreenCommand(PasteCommandType::ScreenAll);
3076 return D_O_K;
3077 }
3078
3079 int32_t onPasteToAll()
3080 {
3081 if(confirmBox("You are about to paste to all screens on the current map."))
3082 {
3083 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartialToEveryScreen);
3084 }
3085 return D_O_K;
3086 }
3087
3088 int32_t onPasteAllToAll()
3089 {
3090 if(confirmBox("You are about to paste to all screens on the current map."))
3091 {
3092 Map.DoPasteScreenCommand(PasteCommandType::ScreenAllToEveryScreen);
3093 }
3094 return D_O_K;
3095 }
3096
3097 int32_t onPasteUnderCombo()
3098 {
3099 Map.DoPasteScreenCommand(PasteCommandType::ScreenUnderCombo);
3100 return D_O_K;
3101 }
3102
3103 int32_t onPasteSecretCombos()
3104 {
3105 Map.DoPasteScreenCommand(PasteCommandType::ScreenSecretCombos);
3106 return D_O_K;
3107 }
3108
3109 int32_t onPasteFFCombos()
3110 {
3111 Map.DoPasteScreenCommand(PasteCommandType::ScreenFFCombos);
3112 return D_O_K;
3113 }
3114
3115 int32_t onPasteWarps()
3116 {
3117 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarps);
3118 return D_O_K;
3119 }
3120
3121 int32_t onPasteScreenData()
3122 {
3123 Map.DoPasteScreenCommand(PasteCommandType::ScreenData);
3124 return D_O_K;
3125 }
3126
3127 int32_t onPasteWarpLocations()
3128 {
3129 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarpLocations);
3130 return D_O_K;
3131 }
3132
3133 int32_t onPasteDoors()
3134 {
3135 Map.DoPasteScreenCommand(PasteCommandType::ScreenDoors);
3136 return D_O_K;
3137 }
3138
3139 int32_t onPasteLayers()
3140 {
3141 Map.DoPasteScreenCommand(PasteCommandType::ScreenLayers);
3142 return D_O_K;
3143 }
3144
3145 int32_t onPastePalette()
3146 {
3147 Map.DoPasteScreenCommand(PasteCommandType::ScreenPalette);
3148 return D_O_K;
3149 }
3150
3151 int32_t onPasteRoom()
3152 {
3153 Map.DoPasteScreenCommand(PasteCommandType::ScreenRoom);
3154 return D_O_K;
3155 }
3156
3157 int32_t onPasteGuy()
3158 {
3159 Map.DoPasteScreenCommand(PasteCommandType::ScreenGuy);
3160 return D_O_K;
3161 }
3162
3163 int32_t onPasteEnemies()
3164 {
3165 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies);
3166 return D_O_K;
3167 }
3168
3169 int32_t onDelete()
3170 {
3171 restore_mouse();
3172
3173 if(!(Map.CurrScr()->valid&mVALID) || jwin_alert("Confirm Delete","Delete this screen?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3174 {
3175 Map.DoClearScreenCommand();
3176 }
3177
3178 reset_relational_tile_grid();
3179 saved=false;
3180 return D_O_K;
3181 }
3182
3183 int32_t onDeleteMap()
3184 {
3185 if(jwin_alert("Confirm Delete","Clear this entire map?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3186 {
3187 Map.clearmap(false);
3188 refresh(rALL);
3189 saved=false;
3190 }
3191
3192 return D_O_K;
3193 }
3194
3195 int32_t onToggleDarkness()
3196 {
3197 Map.CurrScr()->flags^=4;
3198 refresh(rMAP+rMENU);
3199 saved=false;
3200 return D_O_K;
3201 }
3202
3203 int32_t onIncMap()
3204 {
3205 int32_t m=Map.getCurrMap();
3206 int32_t oldcolor=Map.getcolor();
3207 Map.setCurrMap(m+1>=map_count?0:m+1);
3208 Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3209 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3210 if(m!=Map.getCurrMap())
3211 {
3212 reset_relational_tile_grid();
3213 }
3214
3215 int32_t newcolor=Map.getcolor();
3216
3217 if(newcolor!=oldcolor)
3218 {
3219 rebuild_trans_table();
3220 }
3221
3222 refresh(rALL);
3223 return D_O_K;
3224 }
3225
3226 int32_t onDecMap()
3227 {
3228 int32_t m=Map.getCurrMap();
3229 int32_t oldcolor=Map.getcolor();
3230 Map.setCurrMap((m-1<0)?map_count-1:zc_min(m-1,map_count-1));
3231 Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3232 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3233
3234 if(m!=Map.getCurrMap())
3235 {
3236 reset_relational_tile_grid();
3237 }
3238
3239 int32_t newcolor=Map.getcolor();
3240
3241 if(newcolor!=oldcolor)
3242 {
3243 rebuild_trans_table();
3244 }
3245
3246 refresh(rALL);
3247 return D_O_K;
3248 }
3249
3250
3251 int32_t onDefault_Pals()
3252 {
3253 if(jwin_alert("Confirm Reset","Reset all palette data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3254 {
3255 saved=false;
3256
3257 if(!init_colordata(true, &header, &QMisc))
3258 {
3259 jwin_alert("Error","Palette reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3260 }
3261
3262 refresh_pal();
3263 }
3264
3265 return D_O_K;
3266 }
3267
3268 int32_t onDefault_Combos()
3269 {
3270 if(jwin_alert("Confirm Reset","Reset combo data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3271 {
3272 saved=false;
3273
3274 if(!init_combos(true, &header))
3275 {
3276 jwin_alert("Error","Combo reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3277 }
3278
3279 refresh(rALL);
3280 }
3281
3282 return D_O_K;
3283 }
3284
3285 int32_t onDefault_Items()
3286 {
3287 if(jwin_alert("Confirm Reset","Reset all items?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3288 {
3289 saved=false;
3290 reset_items(true, &header);
3291 }
3292
3293 return D_O_K;
3294 }
3295
3296 int32_t onDefault_Weapons()
3297 {
3298 if(jwin_alert("Confirm Reset","Reset weapon/misc. sprite data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3299 {
3300 saved=false;
3301 reset_wpns(true, &header);
3302 }
3303
3304 return D_O_K;
3305 }
3306
3307 int32_t onDefault_Guys()
3308 {
3309 if(jwin_alert("Confirm Reset","Reset all enemy/NPC data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3310 {
3311 saved=false;
3312 reset_guys();
3313 }
3314
3315 return D_O_K;
3316 }
3317
3318
3319 int32_t onDefault_Tiles()
3320 {
3321 if(jwin_alert("Confirm Reset","Reset all tiles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3322 {
3323 saved=false;
3324
3325 if(!init_tiles(true, &header))
3326 {
3327 jwin_alert("Error","Tile reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3328 }
3329
3330 refresh(rALL);
3331 }
3332
3333 return D_O_K;
3334 }
3335
3336 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2);
3337
3338 int32_t onDefault_SFX()
3339 {
3340 if(jwin_alert("Confirm Reset","Reset all sound effects?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3341 {
3342 saved=false;
3343 SAMPLE *temp_sample;
3344
3345 for(int32_t i=1; i<WAV_COUNT; i++)
3346 {
3347 temp_sample = (SAMPLE *)sfxdata[zc_min(i,Z35)].dat;
3348 change_sfx(&customsfxdata[i], temp_sample);
3349 sprintf(sfx_string[i],"s%03d",i);
3350
3351 if(i<Z35)
3352 strcpy(sfx_string[i], old_sfx_string[i-1]);
3353 set_bit(customsfxflag, i<Z35?1:0, i-1);
3354 }
3355 }
3356
3357 return D_O_K;
3358 }
3359
3360
3361 int32_t onDefault_MapStyles()
3362 {
3363 if(jwin_alert("Confirm Reset","Reset all map styles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3364 {
3365 saved=false;
3366 reset_mapstyles(true, &QMisc);
3367 }
3368
3369 return D_O_K;
3370 }
3371
3372 int onScrollScreen(int dir, bool warp)
3373 {
3374 Map.scroll(dir,warp);
3375 return D_O_K;
3376 }
3377
3378 int32_t onComboColLeft()
3379 {
3380 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3381 ;
3382 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3383 {
3384 First[current_combolist]-=1;
3385 clear_tooltip();
3386 refresh(rCOMBOS);
3387 }
3388 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3389 {
3390 combo_alistpos[current_comboalist]-=1;
3391 clear_tooltip();
3392 refresh(rCOMBOS);
3393 }
3394
3395 clear_keybuf();
3396 return D_O_K;
3397 }
3398
3399 int32_t onComboColRight()
3400 {
3401 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3402 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3403 ;
3404 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3405 {
3406 First[current_combolist]+=1;
3407 clear_tooltip();
3408 refresh(rCOMBOS);
3409 }
3410 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))&&(draw_mode==dm_alias))
3411 {
3412 combo_alistpos[current_comboalist]+=1;
3413 clear_tooltip();
3414 refresh(rCOMBOS);
3415 }
3416
3417 clear_keybuf();
3418 return D_O_K;
3419 }
3420
3421 int32_t onComboColUp()
3422 {
3423 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3424 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3425 ;
3426 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3427 {
3428 First[current_combolist]-=zc_min(First[current_combolist],sqr.w);
3429 clear_tooltip();
3430
3431 refresh(rCOMBOS);
3432 }
3433 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3434 {
3435 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],sqr.w);
3436 clear_tooltip();
3437 refresh(rCOMBOS);
3438 }
3439
3440 clear_keybuf();
3441 return D_O_K;
3442 }
3443
3444 int32_t onComboColDown()
3445 {
3446 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3447
3448 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3449 ;
3450 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3451 {
3452 First[current_combolist]+=zc_min((MAXCOMBOS-sqr.w)-First[current_combolist],sqr.w);
3453 clear_tooltip();
3454 refresh(rCOMBOS);
3455 }
3456 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(comboaliaslist[0].w*comboaliaslist[0].h)))&&(draw_mode==dm_alias))
3457 {
3458 combo_alistpos[current_comboalist]+=zc_min((MAXCOMBOALIASES-sqr.w)-combo_alistpos[current_comboalist],sqr.w);
3459 clear_tooltip();
3460 refresh(rCOMBOS);
3461 }
3462
3463 clear_keybuf();
3464 return D_O_K;
3465 }
3466
3467 void scrollup(int j)
3468 {
3469 switch(draw_mode)
3470 {
3471 case dm_alias:
3472 {
3473 auto& sqr = comboaliaslist[j];
3474 if(combo_alistpos[j]>0)
3475 {
3476 if(CHECK_CTRL_CMD)
3477 {
3478 combo_alistpos[j]=0;
3479 clear_tooltip();
3480 }
3481 else
3482 {
3483 combo_alistpos[j]-=zc_min(combo_alistpos[j],(sqr.w*sqr.h));
3484 clear_tooltip();
3485 }
3486
3487 refresh(rCOMBOS);
3488 }
3489 break;
3490 }
3491 case dm_cpool:
3492 {
3493 auto& sqr = comboaliaslist[j];
3494 if(combo_pool_listpos[j]>0)
3495 {
3496 if(CHECK_CTRL_CMD)
3497 {
3498 combo_pool_listpos[j]=0;
3499 clear_tooltip();
3500 }
3501 else
3502 {
3503 combo_pool_listpos[j]-=zc_min(combo_pool_listpos[j],(sqr.w*sqr.h));
3504 clear_tooltip();
3505 }
3506
3507 refresh(rCOMBOS);
3508 }
3509 break;
3510 }
3511 case dm_auto:
3512 {
3513 auto& sqr = comboaliaslist[j];
3514 if (combo_auto_listpos[j] > 0)
3515 {
3516 if (CHECK_CTRL_CMD)
3517 {
3518 combo_auto_listpos[j] = 0;
3519 clear_tooltip();
3520 }
3521 else
3522 {
3523 combo_auto_listpos[j] -= zc_min(combo_auto_listpos[j], (sqr.w * sqr.h));
3524 clear_tooltip();
3525 }
3526
3527 refresh(rCOMBOS);
3528 }
3529 break;
3530 }
3531 default:
3532 {
3533 auto& sqr = combolist[j];
3534 if(First[j]>0)
3535 {
3536 if(CHECK_CTRL_CMD)
3537 {
3538 First[j]-=zc_min(First[j],256);
3539 clear_tooltip();
3540 }
3541 else
3542 {
3543 First[j]-=zc_min(First[j],(sqr.w*sqr.h));
3544 clear_tooltip();
3545 }
3546
3547 refresh(rCOMBOS);
3548 }
3549 break;
3550 }
3551 }
3552 }
3553 void scrolldown(int j)
3554 {
3555 switch(draw_mode)
3556 {
3557 case dm_alias:
3558 {
3559 auto& sqr = comboaliaslist[j];
3560 if(combo_alistpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3561 {
3562 if(CHECK_CTRL_CMD)
3563 {
3564 combo_alistpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3565 clear_tooltip();
3566 }
3567 else
3568 {
3569 combo_alistpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_alistpos[j]+(sqr.w*sqr.h));
3570 clear_tooltip();
3571 }
3572
3573 refresh(rCOMBOS);
3574 }
3575 break;
3576 }
3577 case dm_cpool:
3578 {
3579 auto& sqr = comboaliaslist[j];
3580 if(combo_pool_listpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3581 {
3582 if(CHECK_CTRL_CMD)
3583 {
3584 combo_pool_listpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3585 clear_tooltip();
3586 }
3587 else
3588 {
3589 combo_pool_listpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_pool_listpos[j]+(sqr.w*sqr.h));
3590 clear_tooltip();
3591 }
3592
3593 refresh(rCOMBOS);
3594 }
3595 break;
3596 }
3597 case dm_auto:
3598 {
3599 auto& sqr = comboaliaslist[j];
3600 if (combo_auto_listpos[j] < (MAXCOMBOALIASES - (sqr.w * sqr.h)))
3601 {
3602 if (CHECK_CTRL_CMD)
3603 {
3604 combo_auto_listpos[j] = MAXCOMBOALIASES - (sqr.w * sqr.h);
3605 clear_tooltip();
3606 }
3607 else
3608 {
3609 combo_auto_listpos[j] = zc_min((MAXCOMBOALIASES - (sqr.w * sqr.h)), combo_pool_listpos[j] + (sqr.w * sqr.h));
3610 clear_tooltip();
3611 }
3612
3613 refresh(rCOMBOS);
3614 }
3615 break;
3616 }
3617 default:
3618 {
3619 auto& sqr = combolist[j];
3620 if(First[j]<(MAXCOMBOS-(sqr.w*sqr.h)))
3621 {
3622 if(CHECK_CTRL_CMD)
3623 {
3624 First[j]=zc_min((MAXCOMBOS-sqr.w*sqr.h),First[j]+256);
3625 clear_tooltip();
3626 }
3627 else
3628 {
3629 First[j]=zc_min((MAXCOMBOS-(sqr.w*sqr.h)),First[j]+(sqr.w*sqr.h));
3630 clear_tooltip();
3631 }
3632
3633 refresh(rCOMBOS);
3634 }
3635 break;
3636 }
3637 }
3638 }
3639
3640 int32_t onPgUp()
3641 {
3642 switch(draw_mode)
3643 {
3644 case dm_alias:
3645 scrollup(current_comboalist);
3646 break;
3647 case dm_cpool:
3648 scrollup(current_cpoollist);
3649 break;
3650 case dm_auto:
3651 scrollup(current_cautolist);
3652 break;
3653 default:
3654 scrollup(current_combolist);
3655 break;
3656 }
3657 return D_O_K;
3658 }
3659
3660 int32_t onPgDn()
3661 {
3662 switch(draw_mode)
3663 {
3664 case dm_alias:
3665 scrolldown(current_comboalist);
3666 break;
3667 case dm_cpool:
3668 scrolldown(current_cpoollist);
3669 break;
3670 case dm_auto:
3671 scrolldown(current_cautolist);
3672 break;
3673 default:
3674 scrolldown(current_combolist);
3675 break;
3676 }
3677 return D_O_K;
3678 }
3679
3680 int32_t onIncreaseCSet()
3681 {
3682 if(draw_mode!=dm_alias)
3683 {
3684 CSet=wrap(CSet+1,0,13);
3685 refresh(rCOMBOS+rMENU+rCOMBO);
3686 }
3687 else
3688 {
3689 alias_cset_mod=wrap(alias_cset_mod+1,0,13);
3690 }
3691 return D_O_K;
3692 }
3693
3694 int32_t onDecreaseCSet()
3695 {
3696 if(draw_mode!=dm_alias)
3697 {
3698 CSet=wrap(CSet-1,0,13);
3699 refresh(rCOMBOS+rMENU+rCOMBO);
3700 }
3701 else
3702 {
3703 alias_cset_mod=wrap(alias_cset_mod-1,0,13);
3704 }
3705 return D_O_K;
3706 }
3707
3708 int32_t onGotoPage()
3709 {
3710 if (draw_mode==dm_alias)
3711 {
3712 static const int PER_PAGE = 260;
3713 if(optional<int> v = call_get_num("Scroll to Alias Page", 0, MAXCOMBOALIASES/PER_PAGE-1, 0))
3714 combo_alistpos[current_comboalist] = *v*PER_PAGE;
3715 }
3716 else if (draw_mode==dm_cpool)
3717 {
3718 static const int PER_PAGE = 260;
3719 if(optional<int> v = call_get_num("Scroll to Combo Pool Page", 0, MAXCOMBOPOOLS/PER_PAGE-1, 0))
3720 combo_pool_listpos[current_cpoollist] = *v*PER_PAGE;
3721 }
3722 else if (draw_mode == dm_auto)
3723 {
3724 static const int PER_PAGE = 260;
3725 if(optional<int> v = call_get_num("Scroll to Auto Combo Page", 0, MAXAUTOCOMBOS/PER_PAGE-1, 0))
3726 combo_auto_listpos[current_cautolist] = *v*PER_PAGE;
3727 }
3728 else
3729 {
3730 static const int PER_PAGE = 256;
3731 if(optional<int> v = call_get_num("Scroll to Combo Page", 0, MAXCOMBOS/PER_PAGE-1, 0))
3732 First[current_combolist] = *v*PER_PAGE;
3733 }
3734
3735 return D_O_K;
3736 }
3737
3738 static char track_number_str_buf[MIDI_TRACK_BUFFER_SIZE] = {0};
3739 const char *tracknumlist(int32_t index, int32_t *list_size)
3740 {
3741 //memset(track_number_str_buf,0,50);
3742 if(index>=0)
3743 {
3744 bound(index,0,255);
3745 std::string name = zcmusic_get_track_name(zcmusic, index);
3746 sprintf(track_number_str_buf,"%02d %s",index+1, name.c_str());
3747 return track_number_str_buf;
3748 }
3749
3750 *list_size=zcmusic_get_tracks(zcmusic);
3751 return NULL;
3752 }
3753
3754 9 static ListData tracknum_list(tracknumlist, &font);
3755
3756 static DIALOG change_track_dlg[] =
3757 {
3758 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
3759 9 { jwin_win_proc, 60-12, 40, 200-16, 72, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Track", NULL, NULL },
3760 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
3761 9 { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
3762 9 { jwin_button_proc, 70, 87, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
3763 9 { jwin_button_proc, 150, 87, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
3764 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
3765 };
3766 // return list_dlg[2].d1;
3767
3768 int32_t changeTrack()
3769 {
3770 restore_mouse();
3771 change_track_dlg[0].dp2=get_zc_font(font_lfont);
3772 change_track_dlg[2].d1=gme_track;
3773
3774 large_dialog(change_track_dlg);
3775
3776 if(do_zqdialog(change_track_dlg,2)==3)
3777 {
3778 gme_track=change_track_dlg[2].d1;
3779 zcmusic_change_track(zcmusic, gme_track);
3780 }
3781
3782 return D_O_K;
3783 }
3784
3785 void set_media_tunes()
3786 {
3787 media_menu.select_uid(MENUID_MEDIA_TUNES, true);
3788 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
3789 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3790 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3791
3792 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3793 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3794 }
3795
3796 int32_t playMusic()
3797 {
3798 char *ext;
3799 bool ismidi=false;
3800 char allmusic_types[256];
3801 sprintf(allmusic_types, "%s;mid", zcmusic_types);
3802
3803 if(prompt_for_existing_file_compat("Load Music",(char*)allmusic_types,NULL,midipath,false))
3804 {
3805 strcpy(midipath,temppath);
3806
3807 ext=get_extension(midipath);
3808
3809 if(
3810 (stricmp(ext,"ogg")==0)||
3811 (stricmp(ext,"mp3")==0)||
3812 (stricmp(ext,"it")==0)||
3813 (stricmp(ext,"xm")==0)||
3814 (stricmp(ext,"s3m")==0)||
3815 (stricmp(ext,"mod")==0)||
3816 (stricmp(ext,"spc")==0)||
3817 (stricmp(ext,"gym")==0)||
3818 (stricmp(ext,"nsf")==0)||
3819 (stricmp(ext,"gbs")==0)||
3820 (stricmp(ext,"vgm")==0)
3821 )
3822 {
3823 ismidi=false;
3824 }
3825 else if((stricmp(ext,"mid")==0))
3826 {
3827 ismidi=true;
3828 }
3829 else
3830 {
3831 return D_O_K;
3832 }
3833
3834 zc_stop_midi();
3835
3836 if(zcmusic != NULL)
3837 {
3838 zcmusic_stop(zcmusic);
3839 zcmusic_unload_file(zcmusic);
3840 zcmusic = NULL;
3841 zcmixer->newtrack = NULL;
3842 }
3843
3844 if(ismidi)
3845 {
3846 packfile_password("");
3847 if((song=load_midi(midipath))!=NULL)
3848 {
3849 if(zc_play_midi(song,true)==0)
3850 {
3851 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3852 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3853 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3854 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3855
3856 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3857 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3858 }
3859 }
3860 }
3861 else
3862 {
3863 gme_track=0;
3864 zcmusic = (ZCMUSIC*)zcmusic_load_file(midipath);
3865
3866 if(zcmusic!=NULL)
3867 {
3868 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3869 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3870 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3871 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3872
3873 bool distrack = zcmusic_get_tracks(zcmusic)<2;
3874 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, distrack);
3875 disable_hotkey(ZQKEY_CHANGE_TRACK, distrack);
3876
3877 zcmusic_play(zcmusic, midi_volume);
3878 }
3879 }
3880 }
3881
3882 return D_O_K;
3883 }
3884
3885 int32_t playZCForever()
3886 {
3887 stopMusic();
3888
3889 zcmusic = zcmusic_load_file("assets/zc/ZC_Forever_HD.mp3");
3890 if (zcmusic)
3891 {
3892 zcmusic_play(zcmusic, midi_volume);
3893 set_media_tunes();
3894 }
3895 return D_O_K;
3896 }
3897
3898 // It took awhile to get these values right, so no meddlin'!
3899 int32_t playTune1()
3900 {
3901 return playTune(0);
3902 }
3903 int32_t playTune2()
3904 {
3905 return playTune(81);
3906 }
3907 int32_t playTune3()
3908 {
3909 return playTune(233);
3910 }
3911 int32_t playTune4()
3912 {
3913 return playTune(553);
3914 }
3915 int32_t playTune5()
3916 {
3917 return playTune(814);
3918 }
3919 int32_t playTune6()
3920 {
3921 return playTune(985);
3922 }
3923 int32_t playTune7()
3924 {
3925 return playTune(1153);
3926 }
3927 int32_t playTune8()
3928 {
3929 return playTune(1333);
3930 }
3931 int32_t playTune9()
3932 {
3933 return playTune(1556);
3934 }
3935 int32_t playTune10()
3936 {
3937 return playTune(1801);
3938 }
3939 int32_t playTune11()
3940 {
3941 return playTune(2069);
3942 }
3943 int32_t playTune12()
3944 {
3945 return playTune(2189);
3946 }
3947 int32_t playTune13()
3948 {
3949 return playTune(2569);
3950 }
3951 int32_t playTune14()
3952 {
3953 return playTune(2753);
3954 }
3955 int32_t playTune15()
3956 {
3957 return playTune(2856);
3958 }
3959 int32_t playTune16()
3960 {
3961 return playTune(3042);
3962 }
3963 int32_t playTune17()
3964 {
3965 return playTune(3125);
3966 }
3967 int32_t playTune18()
3968 {
3969 return playTune(3217);
3970 }
3971 int32_t playTune19()
3972 {
3973 return playTune(3296);
3974 }
3975
3976 int32_t playTune(int32_t pos)
3977 {
3978 zc_stop_midi();
3979
3980 if(zcmusic != NULL)
3981 {
3982 zcmusic_stop(zcmusic);
3983 zcmusic_unload_file(zcmusic);
3984 zcmusic = NULL;
3985 zcmixer->newtrack = NULL;
3986 }
3987
3988 if(zc_play_midi((MIDI*)zcdata[THETRAVELSOFLINK_MID].dat,true)==0)
3989 {
3990 zc_midi_seek(pos);
3991 set_media_tunes();
3992 }
3993
3994 return D_O_K;
3995 }
3996
3997 int32_t stopMusic()
3998 {
3999 zc_stop_midi();
4000
4001 if(zcmusic != NULL)
4002 {
4003 zcmusic_stop(zcmusic);
4004 zcmusic_unload_file(zcmusic);
4005 zcmusic = NULL;
4006 zcmixer->newtrack = NULL;
4007 }
4008
4009 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
4010 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
4011 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
4012 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
4013
4014 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
4015 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
4016 return D_O_K;
4017 }
4018
4019 static int32_t gamemisc1_list[] =
4020 {
4021 5,6,7,8,
4022 9,10,11,12,
4023
4024 37,38,39,40,
4025 41,42,43,44,
4026
4027 71,72,73,74,
4028 75,76,77,78,
4029
4030 -1
4031 };
4032
4033 static int32_t gamemisc2_list[] =
4034 {
4035 13,14,15,16,
4036 17,18,19,20,
4037
4038 45,46,47,48,
4039 49,50,51,52,
4040
4041 79,80,81,82,
4042 83,84,85,86,
4043
4044 -1
4045 };
4046
4047 static int32_t gamemisc3_list[] =
4048 {
4049 21,22,23,24,
4050 25,26,27,28,
4051
4052 53,54,55,56,
4053 57,58,59,60,
4054
4055 87,88,89,90,
4056 91,92,93,94,
4057
4058 -1
4059 };
4060
4061 static int32_t gamemisc4_list[] =
4062 {
4063 29,30,31,32,
4064 33,34,35,36,
4065
4066 61,62,63,64,
4067 65,66,67,68,
4068
4069 95,96,97,98,
4070 99,100,101,102,
4071
4072 -1
4073 };
4074
4075 static TABPANEL gamemisc_tabs[] =
4076 {
4077 // (text)
4078 { (char *)" Misc[0-7] ", D_SELECTED, gamemisc1_list, 0, NULL },
4079 { (char *)" Misc[8-15] ", 0, gamemisc2_list, 0, NULL },
4080 { (char *)" Misc[16-23] ", 0, gamemisc3_list, 0, NULL },
4081 { (char *)" Misc[24-31] ", 0, gamemisc4_list, 0, NULL },
4082 { NULL, 0, NULL, 0, NULL }
4083 };
4084
4085 //to do: Make string boxes larger, and split into two tabs.
4086 static DIALOG gamemiscarray_dlg[] =
4087 {
4088 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
4089
4090 { jwin_win_proc, 0, 10, 310, 224, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Game->Misc[]", NULL, NULL },
4091 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4092 { jwin_tab_proc, 3, 26, 304, 174, vc(14), vc(1), 0, 0, 1, 0, (void *) gamemisc_tabs, NULL, (void *)gamemiscarray_dlg },
4093 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4094 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4095
4096 //5
4097 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4098 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4099 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4100 //8
4101 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4102 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4103 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4104 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4105 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4106 //13
4107 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4108 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4109 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4110 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4111 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4112 //18
4113 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4114 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4115 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4116 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4117 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4118 //23
4119 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4120 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4121 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4122 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4123 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4124 //28
4125 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4126 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4127 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4128 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4129 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4130 //33
4131 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4132 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4133 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4134 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4135 //37
4136 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4137 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4138 //39
4139 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4140 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4141 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4142 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4143 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4144 //44
4145 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4146 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4147 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4148
4149 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4150 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4151 //49
4152 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4153 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4154 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4155 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4156 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4157 //54
4158 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4159 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4160 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4161 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4162 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4163 //59
4164 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4165 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4166 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4167 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4168 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4169 //64
4170 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4171 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4172 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4173 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4174 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4175 //69
4176 { jwin_button_proc, 70, 204, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4177 { jwin_button_proc, 170, 204, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4178
4179 //71
4180 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4181 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4182 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4183 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4184 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4185 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4186 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4187 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4188 //79
4189 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4190 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4191 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4192 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4193 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4194 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4195 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4196 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4197 //87
4198 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4199 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4200 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4201 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4202 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4203 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4204 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4205 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4206 //95
4207 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4208 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4209 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4210 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4211 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4212 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4213 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4214 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4215
4216 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4217 };
4218
4219 // +----------+
4220 // | |
4221 // | View Pic |
4222 // | |
4223 // | |
4224 // | |
4225 // +----------+
4226
4227 BITMAP *pic=NULL;
4228 BITMAP *bmap=NULL;
4229 PALETTE picpal;
4230 PALETTE mappal;
4231 int32_t picx=0,picy=0,mapx=0,mapy=0,pblack,pwhite;
4232
4233 double picscale=1.0,mapscale=1.0;
4234 bool vp_showpal=true, vp_showsize=true, vp_center=true;
4235
4236 //INLINE int32_t pal_sum(RGB p) { return p.r + p.g + p.b; }
4237
4238 void get_bw(RGB *pal,int32_t &black,int32_t &white)
4239 {
4240 black=white=1;
4241
4242 for(int32_t i=1; i<256; i++)
4243 {
4244 if(pal_sum(pal[i])<pal_sum(pal[black]))
4245 black=i;
4246
4247 if(pal_sum(pal[i])>pal_sum(pal[white]))
4248 white=i;
4249 }
4250 }
4251
4252 void draw_bw_mouse(int32_t white, int32_t old_mouse, int32_t new_mouse)
4253 {
4254 blit(mouse_bmp[old_mouse][0],mouse_bmp[new_mouse][0],0,0,0,0,16,16);
4255
4256 for(int32_t y=0; y<16; y++)
4257 {
4258 for(int32_t x=0; x<16; x++)
4259 {
4260 if(getpixel(mouse_bmp[new_mouse][0],x,y)!=0)
4261 {
4262 putpixel(mouse_bmp[new_mouse][0],x,y,white);
4263 }
4264 }
4265 }
4266 }
4267
4268 int32_t load_the_pic(BITMAP **dst, PALETTE dstpal)
4269 {
4270 PALETTE temppal;
4271
4272 for(int32_t i=0; i<256; i++)
4273 {
4274 temppal[i]=dstpal[i];
4275 dstpal[i]=RAMpal[i];
4276 }
4277
4278 // set up the new palette
4279 for(int32_t i=0; i<64; i++)
4280 {
4281 dstpal[i].r = i;
4282 dstpal[i].g = i;
4283 dstpal[i].b = i;
4284 }
4285
4286 zc_set_palette(dstpal);
4287
4288 BITMAP *graypic = create_bitmap_ex(8,screen->w,screen->h);
4289 int32_t _w = screen->w-1;
4290 int32_t _h = screen->h-1;
4291
4292 // gray scale the current frame
4293 for(int32_t y=0; y<_h; y++)
4294 {
4295 for(int32_t x=0; x<_w; x++)
4296 {
4297 int32_t c = screen->line[y][x];
4298 int32_t gray = zc_min((temppal[c].r*42 + temppal[c].g*75 + temppal[c].b*14) >> 7, 63);
4299 graypic->line[y][x] = gray;
4300 }
4301 }
4302
4303 blit(graypic,screen,0,0,0,0,screen->w,screen->h);
4304 destroy_bitmap(graypic);
4305 #ifdef __GNUC__
4306 #pragma GCC diagnostic ignored "-Wformat-overflow"
4307 #endif
4308 char extbuf[2][80];
4309 memset(extbuf[0],0,80);
4310 memset(extbuf[1],0,80);
4311 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4312 strcpy(extbuf[1], snapshotformat_str[0][1]);
4313
4314 for(int32_t i=1; i<ssfmtMAX; ++i)
4315 {
4316 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4317 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4318 }
4319
4320 sprintf(extbuf[0], "%s)", extbuf[0]);
4321 #ifdef __GNUC__
4322 #pragma GCC diagnostic pop
4323 #endif
4324
4325 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4326
4327 if(!gotit)
4328 {
4329 zc_set_palette(temppal);
4330 get_palette(dstpal);
4331 return 1;
4332 }
4333
4334 strcpy(imagepath,temppath);
4335
4336 if(*dst)
4337 {
4338 destroy_bitmap(*dst);
4339 }
4340
4341 for(int32_t i=0; i<256; i++)
4342 {
4343 dstpal[i].r = 0;
4344 dstpal[i].g = 0;
4345 dstpal[i].b = 0;
4346 }
4347
4348 *dst = load_bitmap(imagepath,picpal);
4349
4350 if(!*dst)
4351 {
4352 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4353 return 2;
4354 }
4355
4356 // get_bw(picpal,pblack,pwhite);
4357 // draw_bw_mouse(pwhite);
4358 // gui_bg_color = pblack;
4359 // gui_fg_color = pwhite;
4360
4361 if(vp_center)
4362 {
4363 picx=picy=0;
4364 }
4365 else
4366 {
4367 picx=(*dst)->w-zq_screen_w;
4368 picy=(*dst)->h-zq_screen_h;
4369 }
4370
4371 return 0;
4372 }
4373 int load_the_pic_new(BITMAP **dst, PALETTE dstpal)
4374 {
4375 #ifdef __GNUC__
4376 #pragma GCC diagnostic ignored "-Wformat-overflow"
4377 #endif
4378 char extbuf[2][80];
4379 memset(extbuf[0],0,80);
4380 memset(extbuf[1],0,80);
4381 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4382 strcpy(extbuf[1], snapshotformat_str[0][1]);
4383
4384 for(int32_t i=1; i<ssfmtMAX; ++i)
4385 {
4386 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4387 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4388 }
4389
4390 sprintf(extbuf[0], "%s)", extbuf[0]);
4391 #ifdef __GNUC__
4392 #pragma GCC diagnostic pop
4393 #endif
4394
4395 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4396
4397 if(!gotit)
4398 return 1;
4399
4400 strcpy(imagepath,temppath);
4401
4402 if(*dst)
4403 destroy_bitmap(*dst);
4404
4405 for(int32_t i=0; i<256; i++)
4406 {
4407 dstpal[i].r = 0;
4408 dstpal[i].g = 0;
4409 dstpal[i].b = 0;
4410 }
4411
4412 *dst = load_bitmap(imagepath,dstpal);
4413
4414 if(!*dst)
4415 {
4416 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4417 return 2;
4418 }
4419
4420 if(vp_center)
4421 {
4422 picx=picy=0;
4423 }
4424 else
4425 {
4426 picx=(*dst)->w-zq_screen_w;
4427 picy=(*dst)->h-zq_screen_h;
4428 }
4429
4430 return 0;
4431 }
4432
4433 int32_t saveMapAsImage(ALLEGRO_BITMAP* bitmap)
4434 {
4435 char buf[200];
4436 int32_t num=0;
4437
4438 do
4439 {
4440 snprintf(buf, 200, "%szquest_map%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4441 buf[199]='\0';
4442 }
4443 while(num<99999 && exists(buf));
4444
4445 if (!al_save_bitmap(buf, bitmap))
4446 InfoDialog("Error", "Failed to save map image").show();
4447
4448 return D_O_K;
4449 }
4450
4451 int32_t onViewPic()
4452 {
4453 return launchPicViewer(&pic,picpal,&picx,&picy,&picscale,false);
4454 }
4455
4456
4457 class MapViewRTI : public RenderTreeItem
4458 {
4459 public:
4460
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 MapViewRTI(): RenderTreeItem("map_view")
4461 9 {
4462 9 }
4463
4464 int bw, bh, sw, sh, flags;
4465
4466 private:
4467 void render(bool bitmap_resized)
4468 {
4469 BITMAP* bmap4_single = create_bitmap_ex(8,256,176);
4470 set_bitmap_create_flags(true);
4471 ALLEGRO_BITMAP* bmap5_single = al_create_bitmap(256,176);
4472 int curscr = Map.getCurrScr();
4473 for(int32_t y=0; y<8; y++)
4474 {
4475 for(int32_t x=0; x<16; x++)
4476 {
4477 clear_bitmap(bmap4_single);
4478 Map.setCurrScr(y*16+x);
4479 Map.draw(bmap4_single, 0, 0, flags, -1, y*16+x, -1);
4480 stretch_blit(bmap4_single, bmap4_single, 0, 0, 0, 0, 256, 176, 256, 176);
4481 all_render_a5_bitmap(bmap4_single, bmap5_single);
4482 al_draw_scaled_bitmap(bmap5_single, 0, 0, 256, 176, sw * x, sh * y, sw, sh, 0);
4483 }
4484 }
4485
4486 Map.setCurrScr(curscr);
4487 destroy_bitmap(bmap4_single);
4488 al_destroy_bitmap(bmap5_single);
4489 }
4490 };
4491 9 static MapViewRTI rti_map_view;
4492
4493 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal, int32_t *px2, int32_t *py2, double *scale2, bool isviewingmap, bool skipmenu)
4494 {
4495 restore_mouse();
4496 BITMAP *buf;
4497 bool done=false, redraw=true;
4498
4499 popup_zqdialog_start();
4500
4501 // Always call load_the_map() when viewing the map.
4502 if((!*pictoview || isviewingmap) && (isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)))
4503 {
4504 zc_set_palette(RAMpal);
4505 popup_zqdialog_end();
4506 close_the_map();
4507 return D_O_K;
4508 }
4509
4510 get_bw(pal,pblack,pwhite);
4511
4512 int32_t oldfgcolor = gui_fg_color;
4513 int32_t oldbgcolor = gui_bg_color;
4514
4515 buf = create_bitmap_ex(8,zq_screen_w,zq_screen_h);
4516
4517 if(!buf)
4518 {
4519 jwin_alert("Error","Error creating temp bitmap",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4520 popup_zqdialog_end();
4521 close_the_map();
4522 return D_O_K;
4523 }
4524
4525 static LegacyBitmapRTI viewer_overlay_rti("viewer_overlay");
4526 viewer_overlay_rti.set_size(buf->w, buf->h);
4527 viewer_overlay_rti.a4_bitmap = buf;
4528 viewer_overlay_rti.transparency_index = 15;
4529 get_root_rti()->add_child(&viewer_overlay_rti);
4530
4531 zc_set_palette(pal);
4532
4533 if(isviewingmap)
4534 {
4535 int sw = rti_map_view.width / 16;
4536 int sh = rti_map_view.height / 8;
4537 int scr = Map.getCurrScr();
4538 if (scr >= 0x00 && scr <= 0x7F)
4539 {
4540 int dw = al_get_display_width(all_get_display()) / get_root_rti()->get_transform().xscale;
4541 int dh = al_get_display_height(all_get_display()) / get_root_rti()->get_transform().yscale;
4542 mapx = (-(scr % 16) * sw - sw/2 + dw/2);
4543 mapy = (-(scr / 16) * sh - sh/2 + dh/2);
4544 }
4545 }
4546
4547 int w, h;
4548 if (isviewingmap)
4549 {
4550 w = rti_map_view.width;
4551 h = rti_map_view.height;
4552 }
4553 else
4554 {
4555 w = (*pictoview)->w;
4556 h = (*pictoview)->h;
4557 }
4558
4559 do
4560 {
4561 if (isviewingmap)
4562 {
4563 float scale = *scale2;
4564 int dw = al_get_display_width(all_get_display()) / get_root_rti()->get_transform().xscale;
4565 int dh = al_get_display_height(all_get_display()) / get_root_rti()->get_transform().yscale;
4566 mapx = std::max(mapx, (int)(-w*scale + dw));
4567 mapy = std::max(mapy, (int)(-h*scale + dh));
4568 mapx = std::min(mapx, 0);
4569 mapy = std::min(mapy, 0);
4570 rti_map_view.set_transform({mapx, mapy, scale, scale});
4571 }
4572
4573 if(redraw)
4574 {
4575 clear_to_color(buf,15);
4576
4577 if (!isviewingmap)
4578 stretch_blit(*pictoview, buf, 0, 0, w, h,
4579 int32_t(zq_screen_w + (*px2 - w) * *scale2) / 2, int32_t(zq_screen_h + (*py2 - h) * *scale2) / 2,
4580 int32_t(w * *scale2), int32_t(h * *scale2));
4581
4582 if(vp_showpal)
4583 for(int32_t i=0; i<256; i++)
4584 rectfill(buf,((i&15)<<2)+zq_screen_w-64,((i>>4)<<2)+zq_screen_h-64,((i&15)<<2)+zq_screen_w-64+3,((i>>4)<<2)+zq_screen_h-64+3,i);
4585
4586 if(vp_showsize)
4587 {
4588 textprintf_ex(buf,font,0,zq_screen_h-8,pwhite,pblack,"%dx%d %.2f%%",w,h,*scale2*100.0);
4589 }
4590
4591 if (!isviewingmap)
4592 blit(buf,screen,0,0,0,0,zq_screen_w,zq_screen_h);
4593 redraw=false;
4594 }
4595
4596 custom_vsync();
4597
4598 int32_t step = 16;
4599
4600 if(*scale2 < 1.0)
4601 step = int32_t(4.0/ *scale2);
4602
4603 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
4604 step <<= 2;
4605
4606 if(CHECK_CTRL_CMD)
4607 step >>= 1;
4608
4609 if(key[KEY_UP])
4610 {
4611 *py2+=step;
4612 redraw=true;
4613 }
4614
4615 if(key[KEY_DOWN])
4616 {
4617 *py2-=step;
4618 redraw=true;
4619 }
4620
4621 if(key[KEY_LEFT])
4622 {
4623 *px2+=step;
4624 redraw=true;
4625 }
4626
4627 if(key[KEY_RIGHT])
4628 {
4629 *px2-=step;
4630 redraw=true;
4631 }
4632
4633 if(keypressed() && !redraw)
4634 switch(readkey()>>8)
4635 {
4636 case KEY_PGUP:
4637 *scale2*=0.95;
4638
4639 if(*scale2<0.1) *scale2=0.1;
4640
4641 redraw=true;
4642 break;
4643
4644 case KEY_PGDN:
4645 *scale2/=0.95;
4646
4647 if(*scale2>5.0) *scale2=5.0;
4648
4649 redraw=true;
4650 break;
4651
4652 case KEY_HOME:
4653 *scale2/=2.0;
4654
4655 if(*scale2<0.1) *scale2=0.1;
4656
4657 redraw=true;
4658 break;
4659
4660 case KEY_END:
4661 *scale2*=2.0;
4662
4663 if(*scale2>5.0) *scale2=5.0;
4664
4665 redraw=true;
4666 break;
4667
4668 case KEY_TILDE:
4669 *scale2=0.5;
4670 redraw=true;
4671 break;
4672
4673 case KEY_Z:
4674 *px2=w-zq_screen_w;
4675 *py2=h-zq_screen_h;
4676 vp_center=false;
4677 redraw=true;
4678 break;
4679
4680 case KEY_1:
4681 *scale2=1.0;
4682 redraw=true;
4683 break;
4684
4685 case KEY_2:
4686 *scale2=2.0;
4687 redraw=true;
4688 break;
4689
4690 case KEY_3:
4691 *scale2=3.0;
4692 redraw=true;
4693 break;
4694
4695 case KEY_4:
4696 *scale2=4.0;
4697 redraw=true;
4698 break;
4699
4700 case KEY_5:
4701 *scale2=5.0;
4702 redraw=true;
4703 break;
4704
4705 case KEY_C:
4706 *px2=*py2=0;
4707 redraw=vp_center=true;
4708 break;
4709
4710 case KEY_S:
4711 vp_showsize = !vp_showsize;
4712 redraw=true;
4713 break;
4714
4715 case KEY_D:
4716 vp_showpal = !vp_showpal;
4717 redraw=true;
4718 break;
4719
4720 case KEY_P:
4721 if(isviewingmap) break;
4722
4723 case KEY_ESC:
4724 done=true;
4725 break;
4726
4727 case KEY_SPACE:
4728 close_the_map();
4729 // TODO: why is `load_the_map` rendering a black dialog?
4730 if(isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)==2)
4731 {
4732 done=true;
4733 }
4734 else
4735 {
4736 redraw=true;
4737 gui_bg_color = pblack;
4738 gui_fg_color = pwhite;
4739 *scale2=1.0;
4740 zc_set_palette(pal);
4741 }
4742
4743 get_bw(pal,pblack,pwhite);
4744 break;
4745 }
4746 }
4747 while(!done);
4748
4749 destroy_bitmap(buf);
4750 zc_set_palette(RAMpal);
4751 gui_fg_color = oldfgcolor;
4752 gui_bg_color = oldbgcolor;
4753
4754 popup_zqdialog_end();
4755 position_mouse_z(0);
4756 viewer_overlay_rti.remove();
4757 close_the_map();
4758 return D_O_K;
4759 }
4760
4761 static DIALOG loadmap_dlg[] =
4762 {
4763 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
4764 { jwin_win_proc, 0, 0, 225, 143, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Map", NULL, NULL },
4765 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4766 { jwin_text_proc, 32, 26, 96, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Resolution", NULL, NULL },
4767 // 3
4768 { jwin_radio_proc, 16, 36, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/4 - 1024x352", NULL, NULL },
4769 { jwin_radio_proc, 16, 46, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/2 - 2048x704", NULL, NULL },
4770 { jwin_radio_proc, 16, 56, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full - 4096x1408", NULL, NULL },
4771 { jwin_text_proc, 144, 26, 97, 9, vc(11), vc(1), 0, 0, 0, 0, (void *) "Options", NULL, NULL },
4772 // 7
4773 { jwin_check_proc, 144, 36, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Solidity", NULL, NULL },
4774 { jwin_check_proc, 144, 46, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Flags", NULL, NULL },
4775 { jwin_check_proc, 144, 56, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Dark", NULL, NULL },
4776 { jwin_check_proc, 144, 66, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Items", NULL, NULL },
4777 // 11
4778 { jwin_button_proc, 42, 110, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4779 { jwin_button_proc, 122, 110, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4780 { jwin_check_proc, 16, 88, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Save to Image", NULL, NULL },
4781 // 14
4782 { jwin_radio_proc, 16, 66, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"2x - 8192x2816", NULL, NULL },
4783 { jwin_radio_proc, 16, 76, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"4x - 16384x5632", NULL, NULL },
4784 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4785 };
4786
4787 int32_t load_the_map(bool skipmenu)
4788 {
4789 static int32_t res = 0;
4790 static int32_t flags = cDEBUG;
4791
4792 loadmap_dlg[0].dp2 = get_zc_font(font_lfont);
4793 loadmap_dlg[3].flags = (res==2) ? D_SELECTED : 0;
4794 loadmap_dlg[4].flags = (res==1) ? D_SELECTED : 0;
4795 loadmap_dlg[5].flags = (res==0) ? D_SELECTED : 0;
4796 loadmap_dlg[7].flags = (flags&cWALK) ? D_SELECTED : 0;
4797 loadmap_dlg[8].flags = (flags&cFLAGS) ? D_SELECTED : 0;
4798 loadmap_dlg[9].flags = (flags&cNODARK) ? 0 : D_SELECTED;
4799 loadmap_dlg[10].flags = (flags&cNOITEM) ? 0 : D_SELECTED;
4800 loadmap_dlg[13].flags = 0;
4801 loadmap_dlg[14].flags = (res==3) ? D_SELECTED : 0;
4802 loadmap_dlg[15].flags = (res==4) ? D_SELECTED : 0;
4803
4804 if(!skipmenu)
4805 {
4806 large_dialog(loadmap_dlg);
4807
4808 if (do_zqdialog(loadmap_dlg, 11) != 11)
4809 {
4810 return 1;
4811 }
4812
4813 flags = cDEBUG;
4814
4815 if(loadmap_dlg[3].flags&D_SELECTED) res=2;
4816
4817 if(loadmap_dlg[4].flags&D_SELECTED) res=1;
4818
4819 if(loadmap_dlg[5].flags&D_SELECTED) res=0;
4820
4821 if(loadmap_dlg[7].flags&D_SELECTED) flags|=cWALK;
4822
4823 if(loadmap_dlg[8].flags&D_SELECTED) flags|=cFLAGS;
4824
4825 if(!(loadmap_dlg[9].flags&D_SELECTED)) flags|=cNODARK;
4826
4827 if(!(loadmap_dlg[10].flags&D_SELECTED)) flags|=cNOITEM;
4828
4829 if(loadmap_dlg[14].flags&D_SELECTED) res=3;
4830
4831 if(loadmap_dlg[15].flags&D_SELECTED) res=4;
4832 }
4833
4834 int32_t bw = (256*16)>>res;
4835 int32_t bh = (176*8)>>res;
4836 int32_t sw = 256>>res;
4837 int32_t sh = 176>>res;
4838 if(res>2)
4839 {
4840 bw = (256*16)<<(res-2);
4841 bh = (176*8)<<(res-2);
4842 sw = 256<<(res-2);
4843 sh = 176<<(res-2);
4844 }
4845
4846 rti_map_view.flags = flags;
4847 rti_map_view.bw = bw;
4848 rti_map_view.bh = bh;
4849 rti_map_view.sw = sw;
4850 rti_map_view.sh = sh;
4851 rti_map_view.set_size(bw, bh);
4852 rti_map_view.dirty = true;
4853 get_root_rti()->add_child(&rti_map_view);
4854 render_zq();
4855
4856 vp_showpal = false;
4857 get_bw(picpal,pblack,pwhite);
4858 mapx = mapy = 0;
4859 mapscale = 1;
4860 imagepath[0] = 0;
4861
4862 if(loadmap_dlg[13].flags & D_SELECTED) saveMapAsImage(rti_map_view.bitmap);
4863
4864 memcpy(mappal,RAMpal,sizeof(RAMpal));
4865
4866 return 0;
4867 }
4868
4869 void close_the_map()
4870 {
4871 rti_map_view.remove();
4872 }
4873
4874 int32_t onViewMap()
4875 {
4876 return onViewMapEx(false);
4877 }
4878 int32_t onViewMapEx(bool skipmenu)
4879 {
4880 int32_t temp_aligns=ShowMisalignments;
4881 ShowMisalignments=0;
4882 //if(load_the_map()==0)
4883 //{
4884 launchPicViewer(&bmap,mappal,&mapx, &mapy, &mapscale,true,skipmenu);
4885 //}
4886 ShowMisalignments=temp_aligns;
4887 return D_O_K;
4888 }
4889
4890 static const char *mazedirstr[4] = {"North","South","West","East"};
4891 char _pathstr[40]="North,North,North,North";
4892
4893 char *pathstr(byte path[])
4894 {
4895 sprintf(_pathstr,"%s,%s,%s,%s",mazedirstr[path[0]],mazedirstr[path[1]],
4896 mazedirstr[path[2]],mazedirstr[path[3]]);
4897 return _pathstr;
4898 }
4899
4900 char _ticksstr[32]="99.99 seconds";
4901
4902 char *ticksstr(int32_t tics)
4903 {
4904 int32_t mins=tics/(60*60);
4905 tics=tics-(mins*60*60);
4906 int32_t secs=tics/60;
4907 tics=tics-(secs*60);
4908 tics=tics*100/60;
4909
4910 if(mins>0)
4911 {
4912 sprintf(_ticksstr,"%d:%02d.%02d",mins, secs, tics);
4913 }
4914 else
4915 {
4916 sprintf(_ticksstr,"%d.%02d seconds",secs, tics);
4917 }
4918
4919 return _ticksstr;
4920 }
4921 void textprintf_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4922 {
4923 char buf[512];
4924 va_list ap;
4925 ASSERT(bmp);
4926 ASSERT(f);
4927 ASSERT(format);
4928
4929 va_start(ap, format);
4930 uvszprintf(buf, sizeof(buf), format, ap);
4931 va_end(ap);
4932
4933
4934 textout_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
4935
4936 textout_ex(bmp, f, buf, x, y, color_sh, -1);
4937 }
4938
4939 void textprintf_centre_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4940 {
4941 char buf[512];
4942 va_list ap;
4943 ASSERT(bmp);
4944 ASSERT(f);
4945 ASSERT(format);
4946
4947 va_start(ap, format);
4948 uvszprintf(buf, sizeof(buf), format, ap);
4949 va_end(ap);
4950
4951 textout_centre_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
4952 textout_centre_ex(bmp, f, buf, x, y, color_sh, -1);
4953 }
4954
4955 void draw_sqr_frame(size_and_pos const& sqr)
4956 {
4957 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.tw(),sqr.th(),FR_DEEP);
4958 }
4959 void draw_sqr_icon(size_and_pos const& sqr, BITMAP* icon)
4960 {
4961 stretch_blit(icon, menu1, 0, 0, 16, 16, sqr.x+2, sqr.y+2, sqr.tw()-4, sqr.th()-4);
4962 }
4963 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num)
4964 {
4965 if(center)
4966 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
4967 else
4968 textprintf_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
4969 }
4970 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num1, int num2)
4971 {
4972 if(center)
4973 {
4974 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
4975 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
4976 }
4977 else
4978 {
4979 textprintf_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
4980 textprintf_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
4981 }
4982 }
4983 void draw_sqr_btn(size_and_pos const& sqr, const char* txt, int flags, FONT* f = nullptr)
4984 {
4985 if(sqr.x < 0) return;
4986 FONT* tfont = font;
4987 if(f)
4988 font = f;
4989 draw_text_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), txt, 0, 0, flags, true);
4990 font = tfont;
4991 }
4992 void draw_sqr_btn(size_and_pos const& sqr, int icon, int flags, FONT* f = nullptr)
4993 {
4994 if(sqr.x < 0) return;
4995 FONT* tfont = font;
4996 if(f)
4997 font = f;
4998 draw_icon_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), icon, 0, 0, flags, true);
4999 font = tfont;
5000 }
5001
5002 void drawpanel()
5003 {
5004 mapscr *scr=Map.CurrScr();
5005 int32_t NextCombo=combobuf[Combo].nextcombo;
5006 int32_t NextCSet=(combobuf[Combo].animflags & AF_CYCLENOCSET) ? CSet : combobuf[Combo].nextcset;
5007
5008 FONT* tfont = font;
5009 if(prv_mode)
5010 {
5011 jwin_draw_frame(menu1,0,preview_panel.y,preview_panel.x+preview_panel.w, preview_panel.h, FR_WIN);
5012 rectfill(menu1,preview_panel.x,preview_panel.y+2,preview_panel.x+preview_panel.w-3,preview_panel.y+preview_panel.h-3,jwin_pal[jcBOX]);
5013 }
5014 else
5015 {
5016 auto& sqr = main_panel;
5017 rectfill(menu1,sqr.x,sqr.y,sqr.x+sqr.w-1,sqr.y+sqr.h-1, jwin_pal[jcBOX]);
5018 refresh(rSCRMAP);
5019 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.w,sqr.h, FR_WIN);
5020
5021 font = get_custom_font(CFONT_GUI);
5022 draw_sqr_btn(squarepanel_swap_btn, "SWP", 0);
5023 if(compact_square_panels)
5024 {
5025 textprintf_centre_ex(menu1,font,squarepanel_up_btn.cx(),squarepanel_up_btn.y-text_height(font)-2,jwin_pal[jcBOXFG],-1,"%d",compact_active_panel);
5026 draw_sqr_btn(squarepanel_up_btn, BTNICON_ARROW_UP, 0);
5027 draw_sqr_btn(squarepanel_down_btn, BTNICON_ARROW_DOWN, 0);
5028 }
5029 font = tfont;
5030
5031 FONT* sqr_text_font = (is_compact && compact_square_panels) ? get_custom_font(CFONT_GUI) : font;
5032 //Item:
5033 if(itemsqr_pos.x > -1)
5034 {
5035 draw_sqr_frame(itemsqr_pos);
5036 if(scr->hasitem && scr->item > 0)
5037 {
5038 rectfill(menu1,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsqr_pos.x+itemsqr_pos.tw()-3,itemsqr_pos.y+itemsqr_pos.th()-3,0);
5039 overtile16_scale(menu1, itemsbuf[scr->item].tile,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsbuf[scr->item].csets&15,0,itemsqr_pos.tw()-4,itemsqr_pos.th()-4);
5040 }
5041 else draw_sqr_icon(itemsqr_pos, icon_bmp[0][coord_frame]);
5042 draw_sqr_nums(itemsqr_pos, sqr_text_font, panel_align == 1, scr->itemx, scr->itemy);
5043 }
5044 //Flag:
5045 if(flagsqr_pos.x > -1)
5046 {
5047 draw_sqr_frame(flagsqr_pos);
5048 draw_sqr_icon(flagsqr_pos,flag_bmp[Flag%16][coord_frame]);
5049 draw_sqr_nums(flagsqr_pos, sqr_text_font, panel_align == 1, Flag);
5050 }
5051
5052 //Stairs:
5053 if(stairsqr_pos.x > -1)
5054 {
5055 draw_sqr_frame(stairsqr_pos);
5056 draw_sqr_icon(stairsqr_pos,icon_bmp[1][coord_frame]);
5057 draw_sqr_nums(stairsqr_pos, sqr_text_font, panel_align == 1, scr->stairx, scr->stairy);
5058 }
5059
5060 //Green arrival square:
5061 bool disabled_arrival = get_qr(qr_NOARRIVALPOINT);
5062 if(warparrival_pos.x > -1)
5063 {
5064 draw_sqr_frame(warparrival_pos);
5065 BITMAP* icon = icon_bmp[2][coord_frame];
5066 if(disabled_arrival)
5067 {
5068 icon = create_bitmap_ex(8,16,16);
5069 blit(icon_bmp[2][0], icon, 0, 0, 0, 0, 16, 16);
5070 replColor(icon, 0xE7, 0xEA, 0xEA, false);
5071 replColor(icon, 0xE8, 0xE2, 0xE2, false);
5072 }
5073
5074 draw_sqr_icon(warparrival_pos, icon);
5075 draw_sqr_nums(warparrival_pos, sqr_text_font, panel_align == 1, scr->warparrivalx, scr->warparrivaly);
5076
5077 if(disabled_arrival)
5078 destroy_bitmap(icon);
5079 }
5080
5081 //Blue return squares:
5082 for(int32_t i=0; i<4; i++)
5083 {
5084 if(warpret_pos[i].x < 0) continue;
5085 draw_sqr_frame(warpret_pos[i]);
5086 draw_sqr_icon(warpret_pos[i], icon_bmp[ICON_BMP_RETURN_A+i][coord_frame]);
5087 draw_sqr_nums(warpret_pos[i], sqr_text_font, panel_align == 1, scr->warpreturnx[i], scr->warpreturny[i]);
5088 }
5089
5090 // Enemies
5091 auto& ep = enemy_prev_pos;
5092 if(ep.x > -1)
5093 {
5094 if(ep.fw > -1)
5095 {
5096 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5097 rectfill(menu1, ep.x+ep.fw, ep.y+ep.fh, ep.x+ep.tw()-1, ep.y+ep.th()-1, jwin_pal[jcBOX]);
5098 jwin_draw_frag_frame(menu1, ep.x, ep.y, ep.tw(), ep.th(), ep.fw, ep.fh, FR_DEEP);
5099 }
5100 else
5101 {
5102 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5103 draw_sqr_frame(ep);
5104 }
5105 for(int32_t i=0; i< 10 && Map.CurrScr()->enemy[i]!=0; i++)
5106 {
5107 int32_t id = Map.CurrScr()->enemy[i];
5108 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile : guysbuf[id].tile;
5109 int32_t cset = guysbuf[id].cset;
5110 auto& sqr = ep.subsquare(i);
5111 if(tile)
5112 overtile16_scale(menu1, tile+efrontfacingtile(id),sqr.x,sqr.y,cset,0,sqr.tw(),sqr.th());
5113 }
5114 }
5115 }
5116 font = tfont;
5117 }
5118
5119 void show_screen_error(const char *str, int32_t i, int32_t c)
5120 {
5121 rectfill(menu1, screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),screrrorpos.x,screrrorpos.y-((i-1)*16)-4,vc(0));
5122 textout_shadowed_ex(menu1,get_zc_font(font_lfont_l), str,screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),c,vc(0),-1);
5123 }
5124
5125 void tile_warp_notification(int32_t which, char *buf)
5126 {
5127 char letter = 'A'+which;
5128
5129 switch(Map.CurrScr()->tilewarptype[which])
5130 {
5131 case wtCAVE:
5132 sprintf(buf,"Tile Warp %c: Cave/Item Cellar",letter);
5133 break;
5134
5135 default:
5136 {
5137 char buf2[30];
5138
5139 if(strlen(DMaps[Map.CurrScr()->tilewarpdmap[which]].name)==0)
5140 {
5141 sprintf(buf2,"%d",Map.CurrScr()->tilewarpdmap[which]);
5142 }
5143 else
5144 sprintf(buf2,"%d-%s",Map.CurrScr()->tilewarpdmap[which],DMaps[Map.CurrScr()->tilewarpdmap[which]].name);
5145
5146 sprintf(buf,"Tile Warp %c: %s, %02X", letter, buf2, Map.CurrScr()->tilewarpscr[which]);
5147 break;
5148 }
5149
5150 case wtNOWARP:
5151 sprintf(buf,"Tile Warp %c: Cancel Warp", letter);
5152 break;
5153 }
5154 }
5155
5156 void side_warp_notification(int32_t which, int32_t dir, char *buf)
5157 {
5158 char letter = 'A'+which;
5159 char buf3[16];
5160
5161 if(dir==0 && Map.CurrScr()->timedwarptics)
5162 sprintf(buf3,"%s, Timed",mazedirstr[dir]);
5163 else if(dir==4)
5164 sprintf(buf3,"Timed");
5165 else
5166 strcpy(buf3, mazedirstr[dir]);
5167
5168 switch(Map.CurrScr()->sidewarptype[which])
5169 {
5170 case wtCAVE:
5171 sprintf(buf,"Side Warp %c (%s): Cave/Item Cellar",letter, buf3);
5172 break;
5173
5174 default:
5175 {
5176 // Destination DMap name
5177 if(strlen(DMaps[Map.CurrScr()->sidewarpdmap[which]].name)==0)
5178 {
5179 sprintf(buf,"Side Warp %c (%s): %d, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which], Map.CurrScr()->sidewarpscr[which]);
5180 }
5181 else
5182 sprintf(buf,"Side Warp %c (%s): %d-%s, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which],DMaps[Map.CurrScr()->sidewarpdmap[which]].name, Map.CurrScr()->sidewarpscr[which]);
5183
5184 break;
5185 }
5186
5187 case wtNOWARP:
5188 sprintf(buf,"Side Warp %c (%s): Cancel Warp", letter, buf3);
5189 break;
5190 }
5191 }
5192
5193 static bool arrowcursor = true; // Used by combo aliases and Combo Brush cursors. -L
5194
5195 void xout(BITMAP* dest, int x, int y, int x2, int y2, int c, int bgc = -1)
5196 {
5197 //BG Fill
5198 if(bgc > -1)
5199 rectfill(dest, x, y, x2, y2, bgc);
5200 ++x; ++y; --x2; --y2;
5201 //Border
5202 safe_rect(dest, x, y, x2, y2, c);
5203 //line(dest, x, y, x2, y, c);
5204 //line(dest, x, y, x, y2, c);
5205 //X
5206 line(dest, x, y, x2, y2, c);
5207 line(dest, x, y2, x2, y, c);
5208 }
5209
5210 void put_autocombo_engravings(BITMAP* dest, combo_auto const& ca, bool selected, int32_t x, int32_t y, int32_t scale)
5211 {
5212 if (!ca.valid())
5213 {
5214 if (ca.getDisplay() > 0)
5215 put_engraving(dest, x, y, 15, scale);
5216 }
5217 else
5218 {
5219 if (ca.getType() == AUTOCOMBO_Z4 || ca.getType() == AUTOCOMBO_DOR)
5220 {
5221 byte hei = vbound(ca.getArg() + 1, 1, 9);
5222 if (selected)
5223 hei = vbound(cauto_height, 1, 9);
5224 put_engraving(dest, x, y, 15 - hei, scale);
5225 }
5226 }
5227 }
5228
5229 void draw_screenunit(int32_t unit, int32_t flags)
5230 {
5231 FONT* tfont = font;
5232 switch(unit)
5233 {
5234 case rSCRMAP:
5235 {
5236 size_and_pos *mini_sqr = &minimap;
5237 size_and_pos *real_mini_sqr = &real_minimap;
5238
5239 if(zoomed_minimap)
5240 {
5241 mini_sqr = &minimap_zoomed;
5242 real_mini_sqr = &real_minimap_zoomed;
5243 }
5244
5245 auto txt_x = real_mini_sqr->x+2+8*real_mini_sqr->xscale;
5246 auto txt_y = real_mini_sqr->y+2+8*real_mini_sqr->yscale;
5247
5248 rectfill(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->x+mini_sqr->w-1,mini_sqr->y+mini_sqr->h-1,jwin_pal[jcBOX]);
5249 if(zoomed_minimap)
5250 jwin_draw_frame(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->w,mini_sqr->h,FR_WIN);
5251 jwin_draw_minimap_frame(menu1,real_mini_sqr->x,real_mini_sqr->y,real_mini_sqr->tw(), real_mini_sqr->th(), real_mini_sqr->xscale, FR_DEEP);
5252
5253 if(Map.getCurrMap()<Map.getMapCount())
5254 {
5255 for(int32_t i=0; i<MAPSCRS; i++)
5256 {
5257 auto& sqr = real_mini_sqr->subsquare(i);
5258
5259 if(Map.Scr(i)->valid&mVALID)
5260 {
5261 // Handled by mmap_draw.
5262 }
5263 else
5264 {
5265 if (InvalidBG == 2)
5266 {
5267 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
5268 }
5269 else if (InvalidBG == 1)
5270 {
5271 for(int32_t dy=0; dy<sqr.h; dy++)
5272 {
5273 for(int32_t dx=0; dx<sqr.w; dx++)
5274 {
5275 menu1->line[dy+sqr.y][dx+sqr.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
5276 }
5277 }
5278 }
5279 else
5280 {
5281 int32_t offs = 2*(sqr.w/9);
5282 draw_x(menu1, sqr.x+offs, sqr.y+offs, sqr.x+sqr.w-1-offs, sqr.y+sqr.h-1-offs, vc(15));
5283 }
5284 }
5285 }
5286
5287 int32_t s=Map.getCurrScr();
5288
5289 BITMAP* txtbmp = create_bitmap_ex(8,256,64);
5290 clear_bitmap(txtbmp);
5291 int txtscale = zoomed_minimap ? (is_compact ? 2 : 3) : 1;
5292 font = get_zc_font(font_lfont_l);
5293
5294 int32_t space = text_length(font, "255")+2, spc_s = text_length(font, "S")+2, spc_m = text_length(font, "M")+2;
5295 textprintf_disabled(txtbmp,font,0,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"M");
5296 static int map_shortcut_tooltip_id = ttip_register_id();
5297 ttip_install(map_shortcut_tooltip_id, "Prev map: ,\nNext map: .", txt_x, txt_y, 30, 20, txt_x, txt_y - 60);
5298
5299 textprintf_ex(txtbmp,font,spc_m,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",Map.getCurrMap()+1);
5300
5301 textprintf_disabled(txtbmp,font,spc_m+space,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"S");
5302 textprintf_ex(txtbmp,font,spc_m+space+spc_s,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"0x%02X (%d)",s, s);
5303 masked_stretch_blit(txtbmp, menu1, 0, 0, 256, 64, txt_x, txt_y, 256*txtscale, 64*txtscale);
5304 destroy_bitmap(txtbmp);
5305 }
5306 }
5307 break;
5308 case rMAP:
5309 {
5310 if(!layers_valid(Map.CurrScr()))
5311 fix_layers(Map.CurrScr(), true);
5312
5313 byte bgcol = vc(0);
5314 if (LayerDitherBG > -1)
5315 bgcol = vc(LayerDitherBG);
5316 clear_to_color(mapscreenbmp,0);
5317 if (LayerDitherBG > -1)
5318 {
5319 if (LayerDitherSz > 0)
5320 ditherblit(mapscreenbmp, nullptr, vc(LayerDitherBG), dithChecker, LayerDitherSz);
5321 else
5322 clear_to_color(mapscreenbmp, vc(LayerDitherBG));
5323 }
5324 Map.draw(mapscreenbmp, showedges?16:0, showedges?16:0, Flags, -1, -1, ActiveLayerHighlight ? CurrentLayer : -1);
5325 if(showedges)
5326 {
5327 if(Map.getCurrScr()<128)
5328 {
5329 //not the first row of screens
5330 if(Map.getCurrScr()>15 && !NoScreenPreview)
5331 {
5332 Map.drawrow(mapscreenbmp, 16, 0, Flags, 160, -1, Map.getCurrScr()-16);
5333 }
5334 else
5335 {
5336 Map.drawstaticrow(mapscreenbmp, 16, 0);
5337 }
5338
5339 //not the last row of screens
5340 if(Map.getCurrScr()<112 && !NoScreenPreview)
5341 {
5342 Map.drawrow(mapscreenbmp, 16, 192, Flags, 0, -1, Map.getCurrScr()+16);
5343 }
5344 else
5345 {
5346 Map.drawstaticrow(mapscreenbmp, 16, 192);
5347 }
5348
5349 //not the first column of screens
5350 if(Map.getCurrScr()&0x0F && !NoScreenPreview)
5351 {
5352 Map.drawcolumn(mapscreenbmp, 0, 16, Flags, 15, -1, Map.getCurrScr()-1);
5353 }
5354 else
5355 {
5356 Map.drawstaticcolumn(mapscreenbmp, 0, 16);
5357 }
5358
5359 //not the last column of screens
5360 if((Map.getCurrScr()&0x0F)<15 && !NoScreenPreview)
5361 {
5362 Map.drawcolumn(mapscreenbmp, 272, 16, Flags, 0, -1, Map.getCurrScr()+1);
5363 }
5364 else
5365 {
5366 Map.drawstaticcolumn(mapscreenbmp, 272, 16);
5367 }
5368
5369 //not the first row or first column of screens
5370 if((Map.getCurrScr()>15)&&(Map.getCurrScr()&0x0F) && !NoScreenPreview)
5371 {
5372 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, Map.getCurrScr()-17);
5373 }
5374 else
5375 {
5376 Map.drawstaticblock(mapscreenbmp, 0, 0);
5377 }
5378
5379 //not the first row or last column of screens
5380 if((Map.getCurrScr()>15)&&((Map.getCurrScr()&0x0F)<15) && !NoScreenPreview)
5381 {
5382 Map.drawblock(mapscreenbmp, 272, 0, Flags, 160, -1, Map.getCurrScr()-15);
5383 }
5384 else
5385 {
5386 Map.drawstaticblock(mapscreenbmp, 272, 0);
5387 }
5388
5389 //not the last row or first column of screens
5390 if((Map.getCurrScr()<112)&&(Map.getCurrScr()&0x0F) && !NoScreenPreview)
5391 {
5392 Map.drawblock(mapscreenbmp, 0, 192, Flags, 15, -1, Map.getCurrScr()+15);
5393 }
5394 else
5395 {
5396 Map.drawstaticblock(mapscreenbmp, 0, 192);
5397 }
5398
5399 //not the last row or last column of screens
5400 if((Map.getCurrScr()<112)&&((Map.getCurrScr()&0x0F)<15) && !NoScreenPreview)
5401 {
5402 Map.drawblock(mapscreenbmp, 272, 192, Flags, 0, -1, Map.getCurrScr()+17);
5403 }
5404 else
5405 {
5406 Map.drawstaticblock(mapscreenbmp, 272, 192);
5407 }
5408 }
5409 }
5410
5411 if(showxypos_icon)
5412 {
5413 if(showxypos_color==vc(15))
5414 safe_rect(mapscreenbmp,showxypos_x+(showedges?16:0),showxypos_y+(showedges?16:0),showxypos_x+(showedges?16:0)+showxypos_w-1,showxypos_y+(showedges?16:0)+showxypos_h-1,showxypos_color);
5415 else
5416 rectfill(mapscreenbmp,showxypos_x+(showedges?16:0),showxypos_y+(showedges?16:0),showxypos_x+(showedges?16:0)+showxypos_w-1,showxypos_y+(showedges?16:0)+showxypos_h-1,showxypos_color);
5417 }
5418
5419 if(showxypos_cursor_icon)
5420 {
5421 safe_rect(mapscreenbmp,showxypos_cursor_x+(showedges?16:0),showxypos_cursor_y+(showedges?16:0),showxypos_cursor_x+(showedges?16:0)+showxypos_w-1,showxypos_cursor_y+(showedges?16:0)+showxypos_h-1,showxypos_cursor_color);
5422 }
5423
5424 if(ShowSquares)
5425 {
5426 if(Map.CurrScr()->stairx || Map.CurrScr()->stairy)
5427 {
5428 int32_t x1 = Map.CurrScr()->stairx+(showedges?16:0);
5429 int32_t y1 = Map.CurrScr()->stairy+(showedges?16:0);
5430 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5431 }
5432
5433 if(Map.CurrScr()->warparrivalx || Map.CurrScr()->warparrivaly)
5434 {
5435 int32_t x1 = Map.CurrScr()->warparrivalx +(showedges?16:0);
5436 int32_t y1 = Map.CurrScr()->warparrivaly +(showedges?16:0);
5437 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5438 }
5439
5440 for(int32_t i=0; i<4; i++) if(Map.CurrScr()->warpreturnx[i] || Map.CurrScr()->warpreturny[i])
5441 {
5442 int32_t x1 = Map.CurrScr()->warpreturnx[i]+(showedges?16:0);
5443 int32_t y1 = Map.CurrScr()->warpreturny[i]+(showedges?16:0);
5444 int32_t clr = vc(9);
5445
5446 if(FlashWarpSquare==i)
5447 {
5448 if(!FlashWarpClk)
5449 FlashWarpSquare=-1;
5450 else if(!(--FlashWarpClk%3))
5451 clr = vc(15);
5452 }
5453
5454 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5455 }
5456 }
5457
5458 if(ShowFFCs)
5459 {
5460 mapscr* ffscr = prv_mode?Map.get_prvscr():Map.CurrScr();
5461 for(int32_t i=MAXFFCS-1; i>=0; i--)
5462 {
5463 ffcdata& ff = ffscr->ffcs[i];
5464 if(ff.data !=0 && (CurrentLayer<2 || (ff.flags&ffc_overlay)))
5465 {
5466 auto x = ff.x+(showedges?16:0);
5467 auto y = ff.y+(showedges?16:0);
5468 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5469 }
5470 }
5471 }
5472
5473 if(!(Flags&cDEBUG) && pixeldb==1)
5474 {
5475 for(int32_t j=168; j<176; j++)
5476 {
5477 for(int32_t i=0; i<256; i++)
5478 {
5479 if(((i^j)&1)==0)
5480 {
5481 putpixel(mapscreenbmp,(showedges?16:0)+i,
5482 (showedges?16:0)+j,vc(blackout_color));
5483 }
5484 }
5485 }
5486 }
5487
5488 if(mapscreensize==1)
5489 {
5490 blit(mapscreenbmp,menu1,0,0,mapscreen_x,mapscreen_y,mapscreenbmp->w,mapscreenbmp->h);
5491 }
5492 else
5493 {
5494 stretch_blit(mapscreenbmp,menu1,0,0,mapscreenbmp->w,mapscreenbmp->h,mapscreen_x,mapscreen_y,int32_t(mapscreensize*mapscreenbmp->w),int32_t(mapscreensize*mapscreenbmp->h));
5495 }
5496
5497 if(showedges)
5498 {
5499 //top preview
5500 for(int32_t j=0; j<int32_t(16*mapscreensize); j++)
5501 {
5502 for(int32_t i=0; i<288*mapscreensize; i++)
5503 {
5504 if(((i^j)&1)==0)
5505 {
5506 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5507 }
5508 }
5509 }
5510
5511 //bottom preview
5512 for(int32_t j=int32_t(192*mapscreensize); j<int32_t(208*mapscreensize); j++)
5513 {
5514 for(int32_t i=0; i<288*mapscreensize; i++)
5515 {
5516 if(((i^j)&1)==0)
5517 {
5518 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5519 }
5520 }
5521 }
5522
5523 //left preview
5524 for(int32_t j=int32_t(16*mapscreensize); j<int32_t(192*mapscreensize); j++)
5525 {
5526 for(int32_t i=0; i<16*mapscreensize; i++)
5527 {
5528 if(((i^j)&1)==0)
5529 {
5530 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5531 }
5532 }
5533
5534 }
5535
5536 //right preview
5537 for(int32_t j=int32_t(16*mapscreensize); j<int32_t(192*mapscreensize); j++)
5538 {
5539 for(int32_t i=int32_t(272*mapscreensize); i<int32_t(288*mapscreensize); i++)
5540 {
5541 if(((i^j)&1)==0)
5542 {
5543 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5544 }
5545 }
5546 }
5547 }
5548
5549 if(!(Flags&cDEBUG) && pixeldb==2)
5550 {
5551 for(int32_t j=int32_t(168*mapscreensize); j<int32_t(176*mapscreensize); j++)
5552 {
5553 for(int32_t i=0; i<int32_t(256*mapscreensize); i++)
5554 {
5555
5556 if(((i^j)&1)==0)
5557 {
5558 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreensize):0)+i),
5559 int32_t(mapscreen_y+(showedges?(16*mapscreensize):0)+j),vc(blackout_color));
5560 }
5561 }
5562 }
5563 }
5564
5565 if(Map.isDark())
5566 {
5567 if((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))
5568 {
5569 BITMAP* tmpDark = create_bitmap_ex(8,16*16,16*11);
5570 BITMAP* tmpDarkTrans = create_bitmap_ex(8,16*16,16*11);
5571 BITMAP* tmpbuf = create_bitmap_ex(8,
5572 mapscreensize*(256+(showedges?32:0)),
5573 mapscreensize*(176+(showedges?32:0)));
5574 BITMAP* tmpbuf2 = create_bitmap_ex(8,
5575 mapscreensize*(256+(showedges?32:0)),
5576 mapscreensize*(176+(showedges?32:0)));
5577 int32_t darkCol = zinit.darkcol;
5578 switch(darkCol) //special cases
5579 {
5580 case BLACK:
5581 darkCol = vc(0);
5582 break;
5583 case WHITE:
5584 darkCol = vc(15);
5585 break;
5586 }
5587 clear_to_color(tmpDark, darkCol);
5588 clear_to_color(tmpDarkTrans, darkCol);
5589 clear_bitmap(tmpbuf);
5590 clear_bitmap(tmpbuf2);
5591 //Handle torch combos
5592 color_map = &trans_table2;
5593 Map.draw_darkness(tmpDark, tmpDarkTrans);
5594 //
5595 mapscr* tmp = Map.CurrScr();
5596 if(tmp->flags9 & fDARK_DITHER)
5597 {
5598 ditherblit(tmpDark, tmpDark, 0, zinit.dither_type, zinit.dither_arg);
5599 ditherblit(tmpDarkTrans, tmpDarkTrans, 0, zinit.dither_type, zinit.dither_arg);
5600 }
5601
5602 if(mapscreensize == 1)
5603 {
5604 blit(tmpDark, tmpbuf, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5605 blit(tmpDarkTrans, tmpbuf2, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5606 }
5607 else
5608 {
5609 stretch_blit(tmpDark, tmpbuf, 0, 0, 16*16, 16*11,
5610 (showedges?16:0)*mapscreensize, (showedges?16:0)*mapscreensize,
5611 (16*16)*mapscreensize, (16*11)*mapscreensize);
5612 stretch_blit(tmpDarkTrans, tmpbuf2, 0, 0, 16*16, 16*11,
5613 (showedges?16:0)*mapscreensize, (showedges?16:0)*mapscreensize,
5614 (16*16)*mapscreensize, (16*11)*mapscreensize);
5615 }
5616
5617 if(tmp->flags9 & fDARK_TRANS)
5618 {
5619 draw_trans_sprite(menu1, tmpbuf, mapscreen_x, mapscreen_y);
5620 }
5621 else
5622 {
5623 masked_blit(tmpbuf,menu1,0,0,mapscreen_x,mapscreen_y,tmpbuf->w,tmpbuf->h);
5624 }
5625 draw_trans_sprite(menu1, tmpbuf2, mapscreen_x, mapscreen_y);
5626 color_map = &trans_table;
5627 //
5628 destroy_bitmap(tmpDark);
5629 destroy_bitmap(tmpDarkTrans);
5630 destroy_bitmap(tmpbuf);
5631 destroy_bitmap(tmpbuf2);
5632 }
5633 else if(!(Flags&cNODARK))
5634 {
5635 for(int32_t j=0; j<80*mapscreensize; j++)
5636 {
5637 for(int32_t i=0; i<(80*mapscreensize)-j; i++)
5638 {
5639 if(((i^j)&1)==0)
5640 {
5641 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreensize):0))+i,
5642 int32_t(mapscreen_y+(showedges?(16*mapscreensize):0)+j),vc(blackout_color));
5643 }
5644 }
5645 }
5646 }
5647 }
5648
5649 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
5650 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
5651 bool inrect = isinRect(gui_mouse_x(),gui_mouse_y(),startxint,startyint,(startxint+(256*mapscreensize)-1),(startyint+(176*mapscreensize)-1));
5652
5653 if(!(flags&rNOCURSOR) && ((ComboBrush && !ComboBrushPause)||draw_mode==dm_alias) && inrect)
5654 {
5655 int32_t mgridscale=16*mapscreensize;
5656 if(allowHideMouse)
5657 {
5658 if(arrowcursor)
5659 {
5660 arrowcursor = false;
5661 MouseSprite::set(ZQM_BLANK);
5662 }
5663 }
5664 else if(!arrowcursor)
5665 {
5666 arrowcursor = true;
5667 MouseSprite::set(ZQM_NORMAL);
5668 }
5669 int32_t mx=(gui_mouse_x()-mapscreen_x)/mgridscale*mgridscale;
5670 int32_t my=(gui_mouse_y()-mapscreen_y)/mgridscale*mgridscale;
5671 clear_bitmap(brushscreen);
5672 int32_t tempbw=BrushWidth;
5673 int32_t tempbh=BrushHeight;
5674
5675 if(draw_mode==dm_alias)
5676 {
5677 BrushWidth = combo_aliases[combo_apos].width+1;
5678 BrushHeight = combo_aliases[combo_apos].height+1;
5679 }
5680 else if(draw_mode == dm_cpool)
5681 {
5682 BrushWidth = BrushHeight = 1;
5683 combo_pool const& pool = combo_pools[combo_pool_pos];
5684 if(pool.valid())
5685 {
5686 int32_t cid = Combo;
5687 int8_t cset = CSet;
5688 pool.get_w_wrap(cid,cset,cpoolbrush_index/16); //divide to reduce speed
5689 put_combo(brushbmp,0,0,cid,cset,Flags&(cFLAGS|cWALK),0);
5690 }
5691 else clear_bitmap(brushbmp);
5692 }
5693 else if (draw_mode == dm_auto)
5694 {
5695 BrushWidth = BrushHeight = 1;
5696 /*combo_auto const& pool = combo_autos[combo_auto_pos];
5697 if (pool.valid())
5698 {
5699 int32_t cid = Combo;
5700 int8_t cset = CSet;
5701 pool.get_w_wrap(cid, cset, cpoolbrush_index / 16); //divide to reduce speed
5702 put_combo(brushbmp, 0, 0, cid, cset, Flags & (cFLAGS | cWALK), 0);
5703 }
5704 else clear_bitmap(brushbmp);*/
5705 }
5706
5707 if((FloatBrush)&&(draw_mode!=dm_alias))
5708 {
5709 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx-(SHADOW_DEPTH*mapscreensize), my-(SHADOW_DEPTH*mapscreensize), BrushWidth*mgridscale, BrushHeight*mgridscale);
5710
5711 //shadow
5712 for(int32_t i=0; i<SHADOW_DEPTH*mapscreensize; i++)
5713 {
5714 for(int32_t j=0; j<BrushHeight*mgridscale; j++)
5715 {
5716 if((((i^j)&1)==1) && (my+j)<12*mgridscale)
5717 {
5718 putpixel(brushscreen,mx+i+(BrushWidth*mgridscale)-(SHADOW_DEPTH*mapscreensize),my+j,vc(0));
5719 }
5720 }
5721 }
5722
5723 for(int32_t i=0; i<BrushWidth*mgridscale; i++)
5724 {
5725 for(int32_t j=0; j<SHADOW_DEPTH*mapscreensize; j++)
5726 {
5727 if((((i^j)&1)==1) && (mx+i)<16*mgridscale)
5728 {
5729 putpixel(brushscreen,mx+i,my+j+(BrushHeight*mgridscale)-(SHADOW_DEPTH*mapscreensize),vc(0));
5730 }
5731 }
5732 }
5733 }
5734 else
5735 {
5736 if(draw_mode!=dm_alias)
5737 {
5738 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx, my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5739 }
5740 else
5741 {
5742 combo_alias *combo = &combo_aliases[combo_apos];
5743
5744 switch(alias_origin)
5745 {
5746 case 0:
5747 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, mx, my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5748 break;
5749
5750 case 1:
5751 stretch_blit(brushbmp, brushscreen, (mx<combo->width*mgridscale)?((combo->width)*16)-mx/mapscreensize:0, 0, BrushWidth*16, BrushHeight*16, zc_max((mx-(combo->width)*mgridscale),0), my, BrushWidth*mgridscale, BrushHeight*mgridscale);
5752 break;
5753
5754 case 2:
5755 stretch_blit(brushbmp, brushscreen, 0, (my<combo->height*mgridscale)?((combo->height)*16)-my/mapscreensize:0, BrushWidth*16, BrushHeight*16, mx, zc_max((my-(combo->height)*mgridscale),0), BrushWidth*mgridscale, BrushHeight*mgridscale);
5756 break;
5757
5758 case 3:
5759 stretch_blit(brushbmp, brushscreen, (mx<combo->width*mgridscale)?((combo->width)*16)-mx/mapscreensize:0, (my<combo->height*mgridscale)?((combo->height)*16)-my/mapscreensize:0, BrushWidth*16, BrushHeight*16, zc_max((mx-(combo->width)*mgridscale),0), zc_max((my-(combo->height)*mgridscale),0), BrushWidth*mgridscale, BrushHeight*mgridscale);
5760 break;
5761 }
5762 }
5763 }
5764
5765 masked_blit(brushscreen, menu1, 0, 0, mapscreen_x, mapscreen_y, (16+(showedges?2:0))*mgridscale, (11+(showedges?2:0))*mgridscale);
5766 BrushWidth=tempbw;
5767 BrushHeight=tempbh;
5768 }
5769 else
5770 {
5771 if(!arrowcursor)
5772 {
5773 MouseSprite::set(ZQM_NORMAL);
5774 arrowcursor = true;
5775 }
5776 }
5777
5778 if(ShowGrid)
5779 {
5780 int32_t w=16;
5781 int32_t h=11;
5782
5783 if(showedges)
5784 {
5785 w=18;
5786 h=13;
5787 }
5788
5789 for(int32_t x=16; x<w*16; x+=16)
5790 {
5791 vline(menu1, (x*mapscreensize)+mapscreen_x, mapscreen_y, mapscreen_y+(h*16*mapscreensize)-1, vc(GridColor));
5792 }
5793
5794 for(int32_t y=16; y<h*16; y+=16)
5795 {
5796 hline(menu1, mapscreen_x, (y*mapscreensize)+mapscreen_y, mapscreen_x+(w*16*mapscreensize)-1, vc(GridColor));
5797 }
5798 }
5799
5800 // Map tabs
5801 font = get_custom_font(CFONT_GUI);
5802
5803 map_page[current_mappage].map=Map.getCurrMap();
5804 map_page[current_mappage].screen=Map.getCurrScr();
5805
5806 for(int32_t btn=0; btn<mappage_count; ++btn)
5807 {
5808 char tbuf[15];
5809 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
5810 draw_layer_button(menu1,map_page_bar[btn].x, map_page_bar[btn].y, map_page_bar[btn].w, map_page_bar[btn].h,tbuf,(btn==current_mappage?D_SELECTED:0));
5811 }
5812 }
5813 break;
5814 case rCOMBOS:
5815 {
5816 auto real_h = combolist_window.h;
5817 jwin_draw_frame(menu1,combolist_window.x,combolist_window.y,combolist_window.w,real_h, FR_WIN);
5818 rectfill(menu1,combolist_window.x+2,combolist_window.y+2,combolist_window.x+combolist_window.w-3,combolist_window.y+real_h-3,jwin_pal[jcBOX]);
5819
5820 //Scrollers
5821 for(int32_t c = 0; c < num_combo_cols; ++c)
5822 {
5823 auto& pos = combolistscrollers[c];
5824
5825 { //Scroll up
5826 auto& p = pos.subsquare(0);
5827 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
5828
5829 for(int32_t i=0; i<3; i++)
5830 {
5831 hline(menu1, p.x+5-i, p.y+4+i, p.x+5+i, jwin_pal[jcBOXFG]);
5832 }
5833 }
5834
5835 { //Scroll down
5836 auto& p = pos.subsquare(1);
5837 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
5838
5839 for(int32_t i=0; i<3; i++)
5840 {
5841 hline(menu1,p.x+5-i,p.y+6-i, p.x+5+i, jwin_pal[jcBOXFG]);
5842 }
5843 }
5844 }
5845
5846 if(draw_mode==dm_alias)
5847 {
5848 if(LinkedScroll)
5849 {
5850 int tmp = current_comboalist;
5851 for(int q = tmp-1; q >= 0; --q)
5852 {
5853 combo_alistpos[q] = combo_alistpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
5854 if(combo_alistpos[q] < 0)
5855 {
5856 tmp = 0;
5857 combo_alistpos[0] = 0;
5858 break;
5859 }
5860 }
5861 for(int q = tmp+1; q < num_combo_cols; ++q)
5862 combo_alistpos[q] = combo_alistpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
5863 for(int q = 0; q < num_combo_cols; ++q)
5864 if(combo_apos >= combo_alistpos[q] && combo_apos < combo_alistpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
5865 {
5866 current_comboalist = q;
5867 break;
5868 }
5869 }
5870 for(int32_t c = 0; c < num_combo_cols; ++c)
5871 {
5872 auto& pos = comboaliaslist[c];
5873 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
5874 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
5875 }
5876
5877 auto& prev = comboalias_preview;
5878 jwin_draw_frame(menu1, prev.x-2, prev.y-2, prev.w+4, prev.h+4,FR_DEEP);
5879
5880 BITMAP *prv = create_bitmap_ex(8,64,64);
5881 clear_bitmap(prv);
5882 int32_t scalefactor = 1;
5883
5884 for(int32_t j=0; j<num_combo_cols; ++j)
5885 {
5886 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
5887 if(combo_alistpos[j] + per_page >= MAXCOMBOALIASES)
5888 combo_alistpos[j] = MAXCOMBOALIASES-per_page;
5889 auto& col = comboaliaslist[j];
5890 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
5891 {
5892 draw_combo_alias_thumbnail(menu1, &combo_aliases[combo_alistpos[j]+i],
5893 (i%col.w)*col.xscale+col.x, (i/col.w)*col.yscale+col.y, col.xscale/16);
5894 }
5895
5896 if((combo_aliases[combo_apos].width>7)||(combo_aliases[combo_apos].height>7))
5897 {
5898 scalefactor=4;
5899 }
5900 else if((combo_aliases[combo_apos].width>3)||(combo_aliases[combo_apos].height>3))
5901 {
5902 scalefactor=2;
5903 }
5904
5905
5906 if(j==current_comboalist)
5907 {
5908 stretch_blit(brushbmp, prv, 0,0,scalefactor*64,zc_min(scalefactor*64,176),0,0,64,scalefactor==4?44:64);
5909 blit(prv,menu1,0,0,comboalias_preview.x,comboalias_preview.y,comboalias_preview.w,comboalias_preview.h);
5910
5911 int32_t rect_pos=combo_apos-combo_alistpos[current_comboalist];
5912
5913 if((rect_pos>=0)&&(rect_pos<(combo_alistpos[current_comboalist]+(col.w*col.h))))
5914 {
5915 int selw = col.xscale;
5916 int selh = col.yscale;
5917 int x1 = (rect_pos&(col.w-1))*col.xscale+col.x;
5918 int y1 = (rect_pos/col.w)*col.yscale+col.y;
5919 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
5920 }
5921 }
5922 }
5923
5924 destroy_bitmap(prv);
5925 }
5926 else if(draw_mode==dm_cpool)
5927 {
5928 if(LinkedScroll)
5929 {
5930 int tmp = current_cpoollist;
5931 for(int q = tmp-1; q >= 0; --q)
5932 {
5933 combo_pool_listpos[q] = combo_pool_listpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
5934 if(combo_pool_listpos[q] < 0)
5935 {
5936 tmp = 0;
5937 combo_pool_listpos[0] = 0;
5938 break;
5939 }
5940 }
5941 for(int q = tmp+1; q < num_combo_cols; ++q)
5942 combo_pool_listpos[q] = combo_pool_listpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
5943 for(int q = 0; q < num_combo_cols; ++q)
5944 if(combo_pool_pos >= combo_pool_listpos[q] && combo_pool_pos < combo_pool_listpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
5945 {
5946 current_cpoollist = q;
5947 break;
5948 }
5949 }
5950 for(int32_t c = 0; c < num_combo_cols; ++c)
5951 {
5952 auto& pos = comboaliaslist[c];
5953 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
5954 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*comboaliaslist[c].xscale)+4,(pos.h*comboaliaslist[c].yscale)+4,FR_DEEP);
5955 }
5956
5957 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
5958 {
5959 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
5960 if(combo_pool_listpos[j] + per_page >= MAXCOMBOPOOLS)
5961 combo_pool_listpos[j] = MAXCOMBOPOOLS-per_page;
5962 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
5963 {
5964 int32_t cid=-1; int8_t cs=CSet;
5965 combo_pool const& cp = combo_pools[combo_pool_listpos[j]+i];
5966
5967 auto& list = comboaliaslist[j];
5968 if(cp.get_w(cid,cs,0) && !combobuf[cid].tile)
5969 {
5970 cid = -1; //no tile to draw
5971 }
5972 auto cx = (i%list.w)*list.xscale+list.x;
5973 auto cy = (i/list.w)*list.yscale+list.y;
5974 put_combo(menu1,cx,cy,cid,cs,Flags&(cFLAGS|cWALK),0,list.xscale/16);
5975 }
5976 }
5977 int32_t rect_pos=combo_pool_pos-combo_pool_listpos[current_cpoollist];
5978
5979 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_cpoollist]+(comboaliaslist[current_cpoollist].w*comboaliaslist[current_cpoollist].h))))
5980 {
5981 int selw = comboaliaslist[current_cpoollist].xscale;
5982 int selh = comboaliaslist[current_cpoollist].yscale;
5983 int x1 = (rect_pos&(comboaliaslist[current_cpoollist].w-1))*comboaliaslist[current_cpoollist].xscale+comboaliaslist[current_cpoollist].x;
5984 int y1 = (rect_pos/comboaliaslist[current_cpoollist].w)*comboaliaslist[current_cpoollist].yscale+comboaliaslist[current_cpoollist].y;
5985 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
5986 }
5987
5988 //Handle Preview
5989 combo_pool const& cpool = combo_pools[combo_pool_pos];
5990
5991 int32_t cid; int8_t cs;
5992 size_t total = weighted_cpool ? cpool.getTotalWeight() : cpool.combos.size();
5993 size_t ind = 0;
5994 size_t indw = combopool_preview.w/16;
5995 size_t indh = combopool_preview.h/16;
5996 size_t rows = total ? vbound(total/indw,1,indh) : 0;
5997 if (is_compact)
5998 rows = vbound(rows, 1, 3);
5999 else
6000 rows = vbound(rows, 1, 4);
6001 size_t real_height = rows*16;
6002
6003 cpool_prev_visible = rows > 0;
6004 if(rows)
6005 {
6006 jwin_draw_frame(menu1,combopool_preview.x-2,combopool_preview.y-2,
6007 combopool_preview.w+4,real_height+4,FR_DEEP);
6008 rectfill(menu1,combopool_preview.x,combopool_preview.y,
6009 combopool_preview.x+combopool_preview.w-1,
6010 combopool_preview.y+real_height-1,vc(0));
6011 draw_text_button(menu1,combopool_prevbtn.x,combopool_prevbtn.y,
6012 combopool_prevbtn.w,combopool_prevbtn.h,
6013 weighted_cpool ? "Weighted" : "Unweighted",vc(1),vc(14),0,true);
6014 if(!is_compact)
6015 textprintf_ex(menu1,font,combopool_prevbtn.x+combopool_prevbtn.w+5,
6016 combopool_prevbtn.y,jwin_pal[jcBOXFG],-1,"Preview");
6017 for(auto y = 0; y < real_height; y += 16)
6018 {
6019 for(auto x = 0; x < combopool_preview.w; x += 16, ++ind)
6020 {
6021 auto nx = combopool_preview.x+x, ny = combopool_preview.y+y;
6022 if(ind < total)
6023 {
6024 cs = CSet;
6025 if(weighted_cpool
6026 ? cpool.get_w(cid,cs,ind)
6027 : cpool.get_ind(cid,cs,ind))
6028 {
6029 put_combo(menu1,nx,ny,cid,cs,Flags&(cFLAGS|cWALK),0);
6030 continue;
6031 }
6032 }
6033 //No combo to display
6034 xout(menu1, nx, ny, nx+15, ny+15, vc(15));
6035 }
6036 }
6037 }
6038 }
6039 else if (draw_mode == dm_auto)
6040 {
6041 if (LinkedScroll)
6042 {
6043 int tmp = current_cautolist;
6044 for (int q = tmp - 1; q >= 0; --q)
6045 {
6046 combo_auto_listpos[q] = combo_auto_listpos[q + 1] - (comboaliaslist[q].w * comboaliaslist[q].h);
6047 if (combo_auto_listpos[q] < 0)
6048 {
6049 tmp = 0;
6050 combo_auto_listpos[0] = 0;
6051 break;
6052 }
6053 }
6054 for (int q = tmp + 1; q < num_combo_cols; ++q)
6055 combo_auto_listpos[q] = combo_auto_listpos[q - 1] + (comboaliaslist[q - 1].w * comboaliaslist[q - 1].h);
6056 for (int q = 0; q < num_combo_cols; ++q)
6057 if (combo_auto_pos >= combo_auto_listpos[q] && combo_auto_pos < combo_auto_listpos[q] + (comboaliaslist[q].w * comboaliaslist[q].h))
6058 {
6059 current_cautolist = q;
6060 break;
6061 }
6062 }
6063 for (int32_t c = 0; c < num_combo_cols; ++c)
6064 {
6065 auto& pos = comboaliaslist[c];
6066 rectfill(menu1, pos.x, pos.y, pos.x + (pos.w * pos.xscale) - 1, pos.y + (pos.h * pos.yscale) - 1, 0);
6067 jwin_draw_frame(menu1, pos.x - 2, pos.y - 2, (pos.w * comboaliaslist[c].xscale) + 4, (pos.h * comboaliaslist[c].yscale) + 4, FR_DEEP);
6068 }
6069
6070 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6071 {
6072 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6073 if(combo_auto_listpos[j] + per_page >= MAXAUTOCOMBOS)
6074 combo_auto_listpos[j] = MAXAUTOCOMBOS-per_page;
6075 for (int32_t i = 0; i < (comboaliaslist[j].w * comboaliaslist[j].h); i++)
6076 {
6077 int32_t cid = -1; int8_t cs = CSet;
6078 combo_auto const& ca = combo_autos[combo_auto_listpos[j] + i];
6079
6080 auto& list = comboaliaslist[j];
6081 cid = ca.getDisplay();
6082 if (cid == 0)
6083 cid = -1;
6084 auto cx = (i % list.w) * list.xscale + list.x;
6085 auto cy = (i / list.w) * list.yscale + list.y;
6086 put_combo(menu1, cx, cy, cid, cs, Flags & (cFLAGS | cWALK), 0, list.xscale / 16);
6087 put_autocombo_engravings(menu1, ca, combo_auto_listpos[j] + i == combo_auto_pos, cx, cy, list.xscale / 16);
6088 }
6089 }
6090 int32_t rect_pos = combo_auto_pos - combo_auto_listpos[current_cautolist];
6091
6092 if ((rect_pos >= 0) && (rect_pos < (combo_auto_listpos[current_cautolist] + (comboaliaslist[current_cautolist].w * comboaliaslist[current_cautolist].h))))
6093 {
6094 int selw = comboaliaslist[current_cautolist].xscale;
6095 int selh = comboaliaslist[current_cautolist].yscale;
6096 int x1 = (rect_pos & (comboaliaslist[current_cautolist].w - 1)) * comboaliaslist[current_cautolist].xscale + comboaliaslist[current_cautolist].x;
6097 int y1 = (rect_pos / comboaliaslist[current_cautolist].w) * comboaliaslist[current_cautolist].yscale + comboaliaslist[current_cautolist].y;
6098 safe_rect(menu1, x1, y1, x1 + selw - 1, y1 + selh - 1, vc(CmbCursorCol), 2);
6099
6100 combo_auto const& ca = combo_autos[combo_auto_pos];
6101 put_autocombo_engravings(menu1, ca, true, x1, y1, selw / 16);
6102 }
6103 }
6104 else
6105 {
6106 if(LinkedScroll)
6107 {
6108 int tmp = current_combolist;
6109 for(int q = tmp-1; q >= 0; --q)
6110 {
6111 First[q] = First[q+1]-(combolist[q].w*combolist[q].h);
6112 if(First[q] < 0)
6113 {
6114 tmp = 0;
6115 First[0] = 0;
6116 break;
6117 }
6118 }
6119 for(int q = tmp+1; q < num_combo_cols; ++q)
6120 First[q] = First[q-1]+(combolist[q-1].w*combolist[q-1].h);
6121 for(int q = 0; q < num_combo_cols; ++q)
6122 if(Combo >= First[q] && Combo < First[q] + (combolist[q].w*combolist[q].h))
6123 {
6124 current_combolist = q;
6125 break;
6126 }
6127 }
6128 for(int32_t c = 0; c < num_combo_cols; ++c)
6129 {
6130 auto& pos = combolist[c];
6131 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6132 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6133 }
6134
6135 int32_t drawmap, drawscr;
6136 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6137 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6138
6139 for(int32_t j=0; j<num_combo_cols; ++j)
6140 {
6141 auto per_page = (combolist[j].w * combolist[j].h);
6142 if(First[j] + per_page >= MAXCOMBOS)
6143 First[j] = MAXCOMBOS-per_page;
6144 for(int32_t i=0; i<(combolist[j].w*combolist[j].h); i++)
6145 {
6146 put_combo(menu1,(i%combolist[j].w)*combolist[j].xscale+combolist[j].x,
6147 (i/combolist[j].w)*combolist[j].yscale+combolist[j].y,
6148 i+First[j],CSet,Flags&(cFLAGS|cWALK),0,combolist[j].xscale/16);
6149 }
6150 }
6151
6152 int32_t rect_pos=Combo-First[current_combolist];
6153
6154 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_combolist]+(combolist[current_combolist].w*combolist[current_combolist].h))))
6155 {
6156 int selw = (AutoBrush?BrushWidth:1)*combolist[current_combolist].xscale;
6157 int selh = (AutoBrush?BrushHeight:1)*combolist[current_combolist].yscale;
6158 int x1 = (rect_pos&(combolist[current_combolist].w-1))*combolist[current_combolist].xscale+combolist[current_combolist].x;
6159 int y1 = (rect_pos/combolist[current_combolist].w)*combolist[current_combolist].yscale+combolist[current_combolist].y;
6160 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6161 }
6162 }
6163 }
6164 break;
6165 case rCOMBO:
6166 {
6167 int32_t drawmap, drawscr;
6168 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6169 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6170
6171 // Combo preview
6172 int32_t cid = Combo; int8_t cs = CSet;
6173 if(draw_mode == dm_alias)
6174 {
6175 cid = combo_aliases[combo_apos].combos[0];
6176 cs = wrap(combo_aliases[combo_apos].csets[0]+alias_cset_mod, 0, 13);
6177 }
6178 else if(draw_mode == dm_cpool)
6179 {
6180 combo_pool const& cpool = combo_pools[combo_pool_pos];
6181 cid = 0;
6182 cpool.get_w(cid,cs,0);
6183 }
6184 else if (draw_mode == dm_auto)
6185 {
6186 combo_auto const& cauto = combo_autos[combo_auto_pos];
6187 cid = cauto.getDisplay();
6188 }
6189 static BITMAP *combo_preview_bmp=create_bitmap_ex(8,32,32);
6190 static BITMAP *cycle_preview_bmp=create_bitmap_ex(8,32,32);
6191 // Combo
6192 put_combo(combo_preview_bmp,0,0,cid,cs,Flags&(cFLAGS|cWALK),0);
6193 jwin_draw_frame(menu1,combo_preview.x-2,combo_preview.y-2,combo_preview.w+4,combo_preview.h+4, FR_DEEP);
6194 stretch_blit(combo_preview_bmp, menu1, 0, 0, 16, 16, combo_preview.x, combo_preview.y, combo_preview.w, combo_preview.h);
6195
6196 comboprev_buf[0] = 0;
6197 comboprev_buf2[0] = 0;
6198 if(draw_mode == dm_cpool)
6199 {
6200 sprintf(comboprev_buf,"Pool: %d",combo_pool_pos);
6201 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6202 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],comboprev_buf,2,&combo_preview_text1);
6203 }
6204 else if (draw_mode == dm_auto)
6205 {
6206 GUI::ListData ac_types = GUI::ZCListData::autocombotypes();
6207 std::string type_name = ac_types.findText(combo_autos[combo_auto_pos].getType());
6208 if (is_compact)
6209 sprintf(comboprev_buf, "AC: %d CS: %d\n%s", combo_auto_pos, CSet, type_name.c_str());
6210 else
6211 sprintf(comboprev_buf, "Auto: %d CSet: %d\n%s\nEntries: %d", combo_auto_pos, CSet, type_name.c_str(), int32_t(combo_autos[combo_auto_pos].combos.size()));
6212 int x = combo_preview_text1.x + (combo_preview_text1.w * combo_preview_text1.xscale);
6213 textbox_out(menu1, txfont, x, combo_preview_text1.y, jwin_pal[jcBOXFG], jwin_pal[jcBOX], comboprev_buf, 2, &combo_preview_text1);
6214 }
6215 else if(draw_mode != dm_alias)
6216 {
6217 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6218
6219 char shortbuf[512];
6220 char buf[256];
6221 strcpy(buf,combo_class_buf[combobuf[Combo].type].name);
6222 sprintf(comboprev_buf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6223 int ind = strlen(buf)-1;
6224 int x2 = x;
6225 if(x2 - text_length(txfont, buf) <= combolist_window.x)
6226 {
6227 auto dotlen = text_length(txfont, "..");
6228 x2 -= dotlen;
6229 while(x2 - text_length(txfont, buf) <= combolist_window.x)
6230 {
6231 if(ind < 0) break;
6232 buf[ind--] = '\0';
6233 }
6234 while(ind >= 0 && buf[ind] == ' ')
6235 buf[ind--] = 0; //trim spaces
6236 strcat(buf, "..");
6237 }
6238
6239 if(is_compact)
6240 {
6241 char b2[256];
6242 sprintf(b2, "Combo %d CS %d", Combo, CSet);
6243 if(x-text_length(txfont, b2) <= combolist_window.x)
6244 sprintf(b2, "Cmb %d CS %d", Combo, CSet);
6245 sprintf(shortbuf,"%s\n%s",b2,buf);
6246 }
6247 else sprintf(shortbuf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6248 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,2,&combo_preview_text1);
6249 }
6250
6251 // Cycle
6252 if(!is_compact)
6253 {
6254 int32_t NextCombo=combobuf[Combo].nextcombo;
6255 int32_t NextCSet=(combobuf[Combo].animflags & AF_CYCLENOCSET) ? CSet : combobuf[Combo].nextcset;
6256 bool normal_dm = draw_mode != dm_alias && draw_mode != dm_cpool && draw_mode != dm_auto;
6257 jwin_draw_frame(menu1,combo_preview2.x-2,combo_preview2.y-2,combo_preview2.w+4,combo_preview2.h+4, FR_DEEP);
6258 if(NextCombo>0 && normal_dm)
6259 {
6260 put_combo(cycle_preview_bmp,0,0,NextCombo,NextCSet,Flags&(cFLAGS|cWALK),0);
6261
6262 if(Flags&cWALK) put_walkflags(cycle_preview_bmp,0,0,NextCombo,0);
6263
6264 if(Flags&cFLAGS) put_flags(cycle_preview_bmp,0,0,NextCombo,0,cFLAGS,0);
6265
6266 stretch_blit(cycle_preview_bmp, menu1, 0, 0, 16, 16, combo_preview2.x, combo_preview2.y, combo_preview2.w, combo_preview2.h);
6267 }
6268 else
6269 {
6270 if (InvalidBG == 2)
6271 {
6272 draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 32);
6273 }
6274 else if(InvalidBG == 1)
6275 {
6276 for(int32_t dy=0; dy<combo_preview2.w; dy++)
6277 {
6278 for(int32_t dx=0; dx<combo_preview2.w; dx++)
6279 {
6280 menu1->line[dy+combo_preview2.y][dx+combo_preview2.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6281 }
6282 }
6283 }
6284 else
6285 {
6286 rectfill(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(0));
6287 safe_rect(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6288 line(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6289 line(menu1, combo_preview2.x,combo_preview2.y+combo_preview2.h, combo_preview2.x+32,combo_preview2.y,vc(15));
6290 }
6291 }
6292
6293 if(normal_dm)
6294 {
6295 char shortbuf[512];
6296 char buf[256];
6297 strcpy(buf,combo_class_buf[combobuf[NextCombo].type].name);
6298 sprintf(comboprev_buf2, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6299 int ind = strlen(buf)-1;
6300 int x2 = combo_preview_text2.x;
6301 if(x2 + text_length(txfont, buf) > zq_screen_w-2)
6302 {
6303 auto dotlen = text_length(txfont, "..");
6304 x2 += dotlen;
6305 while(x2 + text_length(txfont, buf) > zq_screen_w-2)
6306 {
6307 if(ind < 0) break;
6308 buf[ind--] = '\0';
6309 }
6310 while(ind >= 0 && buf[ind] == ' ')
6311 buf[ind--] = 0; //trim spaces
6312 strcat(buf, "..");
6313 }
6314
6315 sprintf(shortbuf, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6316 textbox_out(menu1,txfont,combo_preview_text2.x,combo_preview_text2.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,0,&combo_preview_text2);
6317 }
6318 }
6319
6320 font = get_zc_font(font_lfont_l);
6321 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
6322 draw_text_button(menu1,combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<",vc(1),vc(14),0,true);
6323 }
6324 break;
6325 case rFAVORITES:
6326 {
6327 font = get_zc_font(font_lfont_l);
6328
6329 jwin_draw_frame(menu1,favorites_window.x,favorites_window.y,favorites_window.w,favorites_window.h, FR_WIN);
6330 rectfill(menu1,favorites_window.x+2,favorites_window.y+2,favorites_window.x+favorites_window.w-3,favorites_window.y+favorites_window.h-3,jwin_pal[jcBOX]);
6331 jwin_draw_frame(menu1,favorites_list.x-2,favorites_list.y-2,(favorites_list.w*favorites_list.xscale)+4,(favorites_list.h*favorites_list.yscale)+4, FR_DEEP);
6332 rectfill(menu1,favorites_list.x,favorites_list.y,favorites_list.x+(favorites_list.w*favorites_list.xscale)-1,favorites_list.y+(favorites_list.h*favorites_list.yscale)-1,jwin_pal[jcBOXFG]);
6333
6334 textprintf_ex(menu1,get_zc_font(font_lfont_l),favorites_list.x-2,favorites_list.y-15,jwin_pal[jcBOXFG],-1,is_compact ? "Favorites" : "Favorite Combos");
6335 BITMAP* subb = create_bitmap_ex(8,16,16);
6336
6337 for(int32_t col=0; col<favorites_list.w; ++col)
6338 {
6339 for(int32_t row=0; row<favorites_list.h; ++row)
6340 {
6341 auto i = (row*FAVORITECOMBO_PER_ROW)+col+FAVORITECOMBO_PER_PAGE*FavoriteComboPage;
6342 auto& sqr = favorites_list.subsquare(col,row);
6343 if(i >= MAXFAVORITECOMBOS || favorite_combos[i]==-1)
6344 {
6345 if (InvalidBG == 2)
6346 {
6347 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
6348 }
6349 else if(InvalidBG == 1)
6350 {
6351 for(int32_t dy=0; dy<sqr.h; dy++)
6352 {
6353 for(int32_t dx=0; dx<sqr.w; dx++)
6354 {
6355 menu1->line[sqr.y+dy][sqr.x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6356 }
6357 }
6358 }
6359 else
6360 {
6361 xout(menu1, sqr.x, sqr.y, sqr.x+sqr.w-1, sqr.y+sqr.h-1, vc(15), vc(0));
6362 }
6363 }
6364 else
6365 {
6366 clear_bitmap(subb);
6367 bool repos = combotile_override_x < 0 && combotile_override_y < 0;
6368
6369 switch(favorite_combo_modes[i])
6370 {
6371 case dm_alias:
6372 draw_combo_alias_thumbnail(subb, &combo_aliases[favorite_combos[i]], 0, 0, 1);
6373 if (ShowFavoriteComboModes)
6374 put_engraving(subb, 0, 0, 0x3E, 1);
6375 break;
6376 case dm_cpool:
6377 {
6378 int32_t cid = -1; int8_t cs = CSet;
6379 combo_pool const& cp = combo_pools[favorite_combos[i]];
6380
6381 if (cp.get_w(cid, cs, 0) && !combobuf[cid].tile)
6382 cid = -1; //no tile to draw
6383 put_combo(subb, 0, 0, cid, cs, 0, 0);
6384 if (ShowFavoriteComboModes)
6385 put_engraving(subb, 0, 0, 0x3D, 1);
6386 break;
6387 }
6388 case dm_auto:
6389 {
6390 int32_t cid = -1; int8_t cs = CSet;
6391 combo_auto const& ca = combo_autos[favorite_combos[i]];
6392
6393 cid = ca.getDisplay();
6394 if (cid == 0)
6395 cid = -1;
6396 put_combo(subb, 0, 0, cid, cs, 0, 0);
6397 if (ShowFavoriteComboModes)
6398 put_engraving(subb, 0, 0, 0x3C, 1);
6399 break;
6400 }
6401 default:
6402 if (repos)
6403 {
6404 combotile_override_x = sqr.x + (sqr.w - 16) / 2;
6405 combotile_override_y = sqr.y + (sqr.h - 16) / 2;
6406 }
6407 put_combo(subb, 0, 0, favorite_combos[i], CSet, Flags & (cFLAGS | cWALK), 0);
6408 if (repos) combotile_override_x = combotile_override_y = -1;
6409 }
6410 stretch_blit(subb, menu1, 0, 0, 16, 16, sqr.x, sqr.y, sqr.w, sqr.h);
6411 }
6412 }
6413 }
6414
6415 destroy_bitmap(subb);
6416
6417 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
6418 if(!is_compact)
6419 textprintf_right_ex(menu1, get_zc_font(font_lfont_l), favorites_pgleft.x - 2, favorites_pgleft.y, jwin_pal[jcBOXFG], -1, "%d/9", FavoriteComboPage + 1);
6420
6421 draw_text_button(menu1, favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-", vc(1), vc(14), 0, true);
6422 draw_text_button(menu1, favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->", vc(1), vc(14), 0, true);
6423 draw_text_button(menu1,favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6424 draw_text_button(menu1,favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X",vc(1),vc(14),0,true);
6425 draw_text_button(menu1,favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?",vc(1),vc(14),0,true);
6426 }
6427 break;
6428 case rCOMMANDS:
6429 {
6430 jwin_draw_frame(menu1,commands_window.x,commands_window.y,commands_window.w,commands_window.h, FR_WIN);
6431 rectfill(menu1,commands_window.x+2,commands_window.y+2,commands_window.x+commands_window.w-3,commands_window.y+commands_window.h-3,jwin_pal[jcBOX]);
6432 jwin_draw_frame(menu1,commands_list.x-2,commands_list.y-2,(commands_list.w*commands_list.xscale)+4,(commands_list.h*commands_list.yscale)+4, FR_DEEP);
6433 rectfill(menu1,commands_list.x,commands_list.y,commands_list.x+(commands_list.w*commands_list.xscale)-1,commands_list.y+(commands_list.h*commands_list.yscale)-1,jwin_pal[jcBOXFG]);
6434 font=get_custom_font(CFONT_FAVCMD);
6435
6436 for(int32_t cmd=0; cmd<(commands_list.w*commands_list.h); ++cmd)
6437 {
6438 uint hkey = favorite_commands[cmd];
6439 draw_layer_button(menu1,
6440 (cmd%commands_list.w)*commands_list.xscale+commands_list.x,
6441 (cmd/commands_list.w)*commands_list.yscale+commands_list.y,
6442 commands_list.xscale,
6443 commands_list.yscale,
6444 get_hotkey_name(hkey),
6445 (selected_hotkey(hkey)?D_SELECTED:0) | (disabled_hotkey(hkey)?D_DISABLED:0));
6446 }
6447
6448 font = get_zc_font(font_lfont_l);
6449 if(commands_txt.x > 0)
6450 {
6451 gui_textout_ln(menu1, get_zc_font(font_lfont_l), (ucc*)"Favorite Commands", commands_txt.x, commands_txt.y, jwin_pal[jcBOXFG], -1, 0);
6452 }
6453
6454 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
6455 draw_text_button(menu1,commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6456 draw_text_button(menu1,commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X",vc(1),vc(14),0,true);
6457 draw_text_button(menu1,commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?",vc(1),vc(14),0,true);
6458 }
6459 break;
6460 }
6461 font = tfont;
6462 }
6463
6464 bool pause_refresh = true;
6465 bool is_refreshing = false;
6466 9 void refresh(int32_t flags, bool update)
6467 {
6468
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pause_refresh) return;
6469 static bool refreshing = false;
6470
6471 bool earlyret = refreshing;
6472 is_refreshing = refreshing = true;
6473 //^ These prevent recursive calls from updating the screen early
6474
6475 bool zoom_delay = (zoomed_minimap && flags != rSCRMAP);
6476 if(zoom_delay)
6477 flags &= ~rSCRMAP;
6478
6479 if(flags&rCLEAR)
6480 {
6481 //magic pink = 0xED
6482 //system black = vc(0)
6483 //Clear a4 menu
6484 clear_to_color(menu1,jwin_pal[jcBOX]);
6485
6486 //Clears should refresh everything!
6487 flags |= rALL;
6488 }
6489
6490 if(flags&rSCRMAP)
6491 draw_screenunit(rSCRMAP,flags);
6492
6493 if(flags&rMAP)
6494 draw_screenunit(rMAP,flags);
6495
6496 if((flags&rCOMBOS) || (draw_mode == dm_cpool && (flags&rFAVORITES)))
6497 draw_screenunit(rCOMBOS,flags);
6498
6499 if(flags&(rCOMBO|rCOMBOS))
6500 draw_screenunit(rCOMBO,flags);
6501
6502 if(flags&rMENU)
6503 drawpanel();
6504
6505 if(flags&rFAVORITES)
6506 draw_screenunit(rFAVORITES,flags);
6507
6508 if(flags&rCOMMANDS)
6509 draw_screenunit(rCOMMANDS,flags);
6510
6511 FONT* tfont = font;
6512 font = get_custom_font(CFONT_GUI);
6513 jwin_draw_frame(menu1,layer_panel.x,layer_panel.y,layer_panel.w,layer_panel.h,FR_DEEP);
6514 rectfill(menu1,layer_panel.x,layer_panel.y,layer_panel.x+layer_panel.w-1,layer_panel.y+layer_panel.h-1,jwin_pal[jcBOX]);
6515
6516 for(int32_t i=0; i<=6; ++i)
6517 {
6518 char tbuf[15];
6519
6520 if(i>0 && Map.CurrScr()->layermap[i-1])
6521 {
6522 if(is_compact)
6523 sprintf(tbuf, "%s%d %d:%02X", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6524 else sprintf(tbuf, "%s%d (%d:%02X)", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6525 }
6526 else
6527 {
6528 sprintf(tbuf, "%s%d", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i);
6529 }
6530
6531 int32_t spacing_offs = is_compact ? 2 : 10;
6532 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
6533 int32_t ry = layer_panel.y;
6534 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
6535 draw_layer_button(menu1, rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf, CurrentLayer==i? D_SELECTED : (!Map.CurrScr()->layermap[i-1] && i>0) ? D_DISABLED : 0);
6536 draw_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]!=0);
6537 }
6538
6539 font=tfont;
6540
6541 // } //if(true)
6542 if(zq_showpal)
6543 {
6544 for(int32_t i=0; i<256; i++)
6545 {
6546 rectfill(menu1,((i&15)<<2)+256,((i>>4)<<2)+176,((i&15)<<2)+259,((i>>4)<<2)+179,i);
6547 }
6548 }
6549 { //Show top-left info
6550 size_t maxwid = (mapscreensize*mapscreenbmp->w)-1;
6551 size_t maxhei = (mapscreensize*mapscreenbmp->w);
6552 set_clip_rect(menu1,mapscreen_x,mapscreen_y,mapscreen_x+maxwid-1,mapscreen_y+maxhei-1);
6553 FONT* showfont = get_custom_font(CFONT_INFO);
6554 int showfont_h = text_height(showfont);
6555 int32_t ypos = mapscreen_y;
6556 if(prv_mode)
6557 {
6558 textout_shadowed_ex(menu1,showfont,"Preview Mode",0,ypos,vc(15),vc(0),infobg?vc(0):-1);
6559 ypos += showfont_h+1;
6560 if(prv_twon)
6561 {
6562 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"T Warp=%d tics", Map.get_prvtime());
6563 ypos += showfont_h+1;
6564 }
6565 }
6566 if(ShowFPS)
6567 {
6568 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"FPS: %3d",lastfps);
6569 ypos += showfont_h+1;
6570 }
6571
6572 if(ShowFFScripts && !prv_mode)
6573 {
6574 word c = Map.CurrScr()->numFFC();
6575 for(word i=0; i< c; i++)
6576 {
6577 if(ypos+showfont_h-1 > map_page_bar[0].y)
6578 break;
6579 if(Map.CurrScr()->ffcs[i].script && Map.CurrScr()->ffcs[i].data)
6580 {
6581 textout_shadowed_ex(menu1, showfont, ffcmap[Map.CurrScr()->ffcs[i].script-1].scriptname.substr(0,300).c_str(),0,ypos,vc(showxypos_ffc==i ? 14 : 15),vc(0),infobg?vc(0):-1);
6582 ypos+=showfont_h+1;
6583 }
6584 }
6585 }
6586 clear_clip_rect(menu1);
6587 if(prv_mode)
6588 do_previewtext();
6589 }
6590 // Show Errors & Details
6591 //This includes the presence of: Screen State Carryover, Timed Warp, Maze Path, the 'Sideview Gravity', 'Invisible Player',
6592 //'Save Screen', 'Continue Here' and 'Treat As..' Screen Flags,
6593 // the String, every Room Type and Catch All, and all four Tile and Side Warps.
6594 if(!prv_mode && ShowInfo)
6595 {
6596 int32_t i=0;
6597 char buf[2048];
6598
6599 // Start with general information
6600 if(Map.CurrScr()->flags3&fINVISHERO)
6601 {
6602 sprintf(buf,"Invisible Player");
6603 show_screen_error(buf,i++,vc(15));
6604 }
6605
6606 if(Map.getLayerTargetMap() > 0)
6607 {
6608 Map.setlayertarget(); //Now the text does not carry over when changing maps, but shifting back, it does not **re-appear** until you change screens.
6609 //It was also required to set some updates in onDecMap and onIncMap. #
6610 //This fixes Screen Info not displaying properly when changing maps. -Z
6611 //Needed to refresh the screen info. -Z ( 26th March, 2019 )
6612 int32_t m = Map.getLayerTargetMultiple();
6613 sprintf(buf,"Used as a layer by screen %d:%02X",Map.getLayerTargetMap(),Map.getLayerTargetScr());
6614 char buf2[24];
6615
6616 if(m>0)
6617 {
6618 sprintf(buf2," and %d other%s",m,m>1?"s":"");
6619 strcat(buf,buf2);
6620 }
6621
6622 show_screen_error(buf,i++,vc(15));
6623 }
6624
6625 if(Map.CurrScr()->nextmap)
6626 {
6627 sprintf(buf,"Screen State carries over to %d:%02X",Map.CurrScr()->nextmap,Map.CurrScr()->nextscr);
6628 show_screen_error(buf,i++,vc(15));
6629 }
6630
6631 if(Map.CurrScr()->timedwarptics)
6632 {
6633 sprintf(buf,"%s%sTimed Warp: %s",(Map.CurrScr()->flags4&fTIMEDDIRECT)?"Direct ":"",(Map.CurrScr()->flags5&fRANDOMTIMEDWARP)?"Random ":"",ticksstr(Map.CurrScr()->timedwarptics));
6634 show_screen_error(buf,i++,vc(15));
6635 }
6636
6637 if(Map.CurrScr()->flags&fMAZE)
6638 {
6639 sprintf(buf,"Maze Path: %s (Exit %s)",pathstr(Map.CurrScr()->path),mazedirstr[Map.CurrScr()->exitdir]);
6640 show_screen_error(buf,i++,vc(15));
6641 }
6642
6643 bool continuescreen = false, savecombo = false;
6644
6645 if(Map.CurrScr()->flags4&fAUTOSAVE)
6646 {
6647 sprintf(buf,"Automatic Save%s Screen", (Map.CurrScr()->flags6&fCONTINUEHERE) ? "-Continue":"");
6648 show_screen_error(buf,i++,vc(15));
6649 continuescreen = ((Map.CurrScr()->flags6&fCONTINUEHERE)!=0);
6650 savecombo = true;
6651 }
6652 else if(Map.CurrScr()->flags6&fCONTINUEHERE)
6653 {
6654 sprintf(buf,"Continue Screen");
6655 show_screen_error(buf,i++,vc(15));
6656 continuescreen = true;
6657 }
6658
6659 if(isSideViewGravity())
6660 {
6661 sprintf(buf,"Sideview Gravity");
6662 show_screen_error(buf,i++,vc(15));
6663 }
6664
6665 if(Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM))
6666 {
6667 sprintf(buf,"Treat As %s%s Screen", (Map.CurrScr()->flags6&fCAVEROOM) ? "Interior":"NES Dungeon",
6668 (Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM)) == (fCAVEROOM|fDUNGEONROOM) ? " or NES Dungeon":"");
6669 show_screen_error(buf,i++,vc(15));
6670 }
6671
6672 if(Map.CurrScr()->oceansfx != 0)
6673 {
6674 sprintf(buf,"Ambient Sound: %s",sfx_string[Map.CurrScr()->oceansfx]);
6675 show_screen_error(buf,i++,vc(15));
6676 }
6677
6678 if(Map.CurrScr()->bosssfx != 0)
6679 {
6680 sprintf(buf,"Boss Roar Sound: %s",sfx_string[Map.CurrScr()->bosssfx]);
6681 show_screen_error(buf,i++,vc(15));
6682 }
6683
6684 if(Map.CurrScr()->str)
6685 {
6686 strncpy(buf,MsgString(Map.CurrScr()->str, true, false),72);
6687 buf[72] = '\0';
6688 char shortbuf[72];
6689 strip_extra_spaces(buf);
6690 shorten_string(shortbuf, buf, get_zc_font(font_lfont_l), 72, 280);
6691 sprintf(buf,"String %s",shortbuf);
6692 show_screen_error(buf,i++,vc(15));
6693 }
6694
6695 if((Map.CurrScr()->flags&fWHISTLE) || (Map.CurrScr()->flags7&fWHISTLEWATER))
6696 {
6697 sprintf(buf,"Whistle ->%s%s%s",(Map.CurrScr()->flags&fWHISTLE)?" Stairs":"",
6698 (Map.CurrScr()->flags&fWHISTLE && Map.CurrScr()->flags7&fWHISTLEWATER)?", ":"",
6699 (Map.CurrScr()->flags7&fWHISTLEWATER)?"Dry Lake":"");
6700 show_screen_error(buf,i++,vc(15));
6701 }
6702
6703 switch(Map.CurrScr()->room)
6704 {
6705 case rSP_ITEM:
6706 sprintf(buf,"Special Item is %s",item_string[Map.CurrScr()->catchall]);
6707 show_screen_error(buf,i++, vc(15));
6708 break;
6709
6710 case rINFO:
6711 {
6712 int32_t shop = Map.CurrScr()->catchall;
6713 sprintf(buf,"Pay For Info: -%d, -%d, -%d",
6714 QMisc.info[shop].price[0],QMisc.info[shop].price[1],QMisc.info[shop].price[2]);
6715 show_screen_error(buf,i++, vc(15));
6716 }
6717 break;
6718
6719 case rMONEY:
6720 sprintf(buf,"Secret Money: %d Rupees",Map.CurrScr()->catchall);
6721 show_screen_error(buf,i++, vc(15));
6722 break;
6723
6724 case rGAMBLE:
6725 show_screen_error("Gamble Room",i++, vc(15));
6726 break;
6727
6728 case rREPAIR:
6729 sprintf(buf,"Door Repair: -%d Rupees",Map.CurrScr()->catchall);
6730 show_screen_error(buf,i++, vc(15));
6731 break;
6732
6733 case rRP_HC:
6734 sprintf(buf,"Take %s or %s", item_string[iRPotion], item_string[iHeartC]);
6735 show_screen_error(buf,i++, vc(15));
6736 break;
6737
6738 case rGRUMBLE:
6739 show_screen_error("Feed the Goriya",i++, vc(15));
6740 break;
6741
6742 case rTRIFORCE:
6743 show_screen_error("Triforce Check",i++, vc(15));
6744 break;
6745
6746 case rP_SHOP:
6747 case rSHOP:
6748 {
6749 int32_t shop = Map.CurrScr()->catchall;
6750 sprintf(buf,"%sShop: ",
6751 Map.CurrScr()->room==rP_SHOP ? "Potion ":"");
6752
6753 for(int32_t j=0; j<3; j++) if(QMisc.shop[shop].item[j]>0) // Print the 3 items and prices
6754 {
6755 strcat(buf,item_string[QMisc.shop[shop].item[j]]);
6756 strcat(buf,":");
6757 char pricebuf[8];
6758 sprintf(pricebuf,"%d",QMisc.shop[shop].price[j]);
6759 strcat(buf,pricebuf);
6760
6761 if(j<2 && QMisc.shop[shop].item[j+1]>0) strcat(buf,", ");
6762 }
6763
6764 show_screen_error(buf,i++, vc(15));
6765 }
6766 break;
6767
6768 case rBOTTLESHOP:
6769 {
6770 int32_t shop = Map.CurrScr()->catchall;
6771 sprintf(buf,"Bottle Shop: ");
6772
6773 for(int32_t j=0; j<3; j++) if(QMisc.bottle_shop_types[shop].fill[j]>0) // Print the 3 fills and prices
6774 {
6775 strcat(buf,QMisc.bottle_types[QMisc.bottle_shop_types[shop].fill[j]-1].name);
6776 strcat(buf,":");
6777 char pricebuf[8];
6778 sprintf(pricebuf,"%d",QMisc.bottle_shop_types[shop].price[j]);
6779 strcat(buf,pricebuf);
6780
6781 if(j<2 && QMisc.bottle_shop_types[shop].fill[j+1]>0) strcat(buf,", ");
6782 }
6783
6784 show_screen_error(buf,i++, vc(15));
6785 }
6786 break;
6787
6788 case rTAKEONE:
6789 {
6790 int32_t shop = Map.CurrScr()->catchall;
6791 sprintf(buf,"Take Only One: %s%s%s%s%s",
6792 QMisc.shop[shop].item[0]<1?"":item_string[QMisc.shop[shop].item[0]],QMisc.shop[shop].item[0]>0?", ":"",
6793 QMisc.shop[shop].item[1]<1?"":item_string[QMisc.shop[shop].item[1]],(QMisc.shop[shop].item[1]>0&&QMisc.shop[shop].item[2]>0)?", ":"",
6794 QMisc.shop[shop].item[2]<1?"":item_string[QMisc.shop[shop].item[2]]);
6795 show_screen_error(buf,i++, vc(15));
6796 }
6797 break;
6798
6799 case rBOMBS:
6800 sprintf(buf,"More Bombs: -%d Rupees",Map.CurrScr()->catchall);
6801 show_screen_error(buf,i++, vc(15));
6802 break;
6803
6804 case rARROWS:
6805 sprintf(buf,"More Arrows: -%d Rupees",Map.CurrScr()->catchall);
6806 show_screen_error(buf,i++, vc(15));
6807 break;
6808
6809 case rSWINDLE:
6810 sprintf(buf,"Leave Life or %d Rupees",Map.CurrScr()->catchall);
6811 show_screen_error(buf,i++, vc(15));
6812 break;
6813
6814 case r10RUPIES:
6815 show_screen_error("10 Rupees",i++, vc(15));
6816 break;
6817
6818 case rGANON:
6819 show_screen_error("Ganon Room",i++, vc(15));
6820 break;
6821
6822 case rZELDA:
6823 show_screen_error("Zelda Room",i++, vc(15));
6824 break;
6825
6826 case rMUPGRADE:
6827 show_screen_error("1/2 Magic Upgrade",i++, vc(15));
6828 break;
6829
6830 case rLEARNSLASH:
6831 show_screen_error("Learn Slash",i++, vc(15));
6832 break;
6833
6834 case rWARP:
6835 sprintf(buf,"3-Stair Warp: Warp Ring %d",Map.CurrScr()->catchall);
6836 show_screen_error(buf,i++, vc(15));
6837 break;
6838 }
6839
6840 bool undercombo = false, warpa = false, warpb = false, warpc = false, warpd = false, warpr = false;
6841
6842 word maxffc = Map.CurrScr()->numFFC();
6843 for(int32_t c=0; c<176+128+1+maxffc; ++c)
6844 {
6845 // Checks both combos, secret combos, undercombos and FFCs
6846 //Fixme:
6847 int32_t ctype =
6848 combobuf[vbound(
6849 (c>=305 ? Map.CurrScr()->ffcs[c-305].data :
6850 c>=304 ? Map.CurrScr()->undercombo :
6851 c>=176 ? Map.CurrScr()->secretcombo[c-176] :
6852 !Map.CurrScr()->valid ? 0 : // Sanity check: does room combo data exist?
6853 Map.CurrScr()->data[c]
6854 ), 0, MAXCOMBOS-1)].type;
6855
6856 if(!undercombo && integrityBoolUnderCombo(Map.CurrScr(),ctype))
6857 {
6858 undercombo = true;
6859 show_screen_error("Under Combo is combo 0",i++, vc(7));
6860 }
6861
6862 // Tile Warp types
6863 switch(ctype)
6864 {
6865 case cSAVE:
6866 case cSAVE2:
6867 if(!savecombo)
6868 {
6869 savecombo = true;
6870
6871 if(integrityBoolSaveCombo(Map.CurrScr(),ctype))
6872 show_screen_error("Save Screen",i++, vc(15));
6873 else
6874 show_screen_error("Save-Continue Screen",i++, vc(15));
6875 }
6876
6877 break;
6878
6879 case cSTAIRR:
6880 case cPITR:
6881 case cSWARPR:
6882 if(!warpr && (Map.CurrScr()->tilewarptype[0]==wtCAVE || Map.CurrScr()->tilewarptype[1]==wtCAVE ||
6883 Map.CurrScr()->tilewarptype[2]==wtCAVE || Map.CurrScr()->tilewarptype[3]==wtCAVE))
6884 {
6885 warpr = true;
6886 show_screen_error("Random Tile Warp contains Cave/Item Cellar",i++, vc(7));
6887 }
6888
6889 break;
6890
6891 case cCAVED:
6892 case cPITD:
6893 case cSTAIRD:
6894 case cCAVE2D:
6895 case cSWIMWARPD:
6896 case cDIVEWARPD:
6897 case cSWARPD:
6898 if(!warpd)
6899 {
6900 warpd = true;
6901 tile_warp_notification(3,buf);
6902 show_screen_error(buf,i++, vc(15));
6903 }
6904
6905 break;
6906
6907 case cCAVEC:
6908 case cPITC:
6909 case cSTAIRC:
6910 case cCAVE2C:
6911 case cSWIMWARPC:
6912 case cDIVEWARPC:
6913 case cSWARPC:
6914 if(!warpc)
6915 {
6916 warpc = true;
6917 tile_warp_notification(2,buf);
6918 show_screen_error(buf,i++, vc(15));
6919 }
6920
6921 break;
6922
6923 case cCAVEB:
6924 case cPITB:
6925 case cSTAIRB:
6926 case cCAVE2B:
6927 case cSWIMWARPB:
6928 case cDIVEWARPB:
6929 case cSWARPB:
6930 if(!warpb)
6931 {
6932 warpb = true;
6933 tile_warp_notification(1,buf);
6934 show_screen_error(buf,i++, vc(15));
6935 }
6936
6937 break;
6938
6939 case cCAVE:
6940 case cPIT:
6941 case cSTAIR:
6942 case cCAVE2:
6943 case cSWIMWARP:
6944 case cDIVEWARP:
6945 case cSWARPA:
6946 if(!warpa)
6947 {
6948 warpa = true;
6949 tile_warp_notification(0,buf);
6950 show_screen_error(buf,i++, vc(15));
6951 }
6952
6953 break;
6954 }
6955 }
6956
6957 int32_t sidewarpnotify = 0;
6958
6959 if(Map.CurrScr()->flags2&wfUP)
6960 {
6961 side_warp_notification(Map.CurrScr()->sidewarpindex&3,0,buf);
6962 show_screen_error(buf,i++, vc(15));
6963 sidewarpnotify|=(1<<(Map.CurrScr()->sidewarpindex&3));
6964 }
6965
6966 if(Map.CurrScr()->flags2&wfDOWN)
6967 {
6968 side_warp_notification((Map.CurrScr()->sidewarpindex>>2)&3,1,buf);
6969 show_screen_error(buf,i++, vc(15));
6970 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>2)&3));
6971 }
6972
6973 if(Map.CurrScr()->flags2&wfLEFT)
6974 {
6975 side_warp_notification((Map.CurrScr()->sidewarpindex>>4)&3,2,buf);
6976 show_screen_error(buf,i++, vc(15));
6977 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>4)&3));
6978 }
6979
6980 if(Map.CurrScr()->flags2&wfRIGHT)
6981 {
6982 side_warp_notification((Map.CurrScr()->sidewarpindex>>6)&3,3,buf);
6983 show_screen_error(buf,i++, vc(15));
6984 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>6)&3));
6985 }
6986
6987 if(!(sidewarpnotify&1) && Map.CurrScr()->timedwarptics)
6988 {
6989 side_warp_notification(0,4,buf); // Timed Warp
6990 show_screen_error(buf,i++, vc(15));
6991 }
6992
6993 // Now for errors
6994 if((Map.CurrScr()->flags4&fSAVEROOM) && !savecombo) show_screen_error("Save Point->Continue Here, but no Save Point combo?",i++, vc(14));
6995
6996 if(integrityBoolEnemiesItem(Map.CurrScr())) show_screen_error("Enemies->Item, but no enemies",i++, vc(7));
6997
6998 if(integrityBoolEnemiesSecret(Map.CurrScr())) show_screen_error("Enemies->Secret, but no enemies",i++, vc(7));
6999
7000 if(integrityBoolStringNoGuy(Map.CurrScr())) show_screen_error("String, but Guy is (none)",i++, vc(14));
7001
7002 if(integrityBoolGuyNoString(Map.CurrScr())) show_screen_error("Non-Fairy Guy, but String is (none)",i++, vc(14));
7003
7004 if(integrityBoolRoomNoGuy(Map.CurrScr())) show_screen_error("Guy is (none)",i++, vc(14));
7005
7006 if(integrityBoolRoomNoString(Map.CurrScr())) show_screen_error("String is (none)",i++, vc(14));
7007
7008 if(integrityBoolRoomNoGuyNoString(Map.CurrScr())) show_screen_error("Guy and String are (none)",i++, vc(14));
7009 }
7010
7011 if(zoom_delay)
7012 draw_screenunit(rSCRMAP,flags);
7013
7014
7015 if(flags&rCLEAR)
7016 {
7017 //Draw the whole gui
7018 blit(menu1,screen,0,0,0,0,zq_screen_w,zq_screen_h);
7019 }
7020 else
7021 {
7022 blit(menu1,screen,0,16,0,16,zq_screen_w,zq_screen_h-16);
7023 blit(menu1,screen,combolist_window.x-64,0,combolist_window.x-64,0,combolist_window.w+64,16);
7024
7025 if(flags&rCOMBO)
7026 blit(menu1,screen,combo_preview.x,combo_preview.y,combo_preview.x,combo_preview.y,combo_preview.w,combo_preview.h);
7027 }
7028
7029 if(earlyret)
7030 return;
7031
7032 //Draw the Main Menu
7033 rectfill(screen,mainbar.x,mainbar.y,mainbar.x+mainbar.w-1,mainbar.y+mainbar.h-1,jwin_pal[jcBOX]);
7034 jwin_draw_frame(screen,mainbar.x,mainbar.y,mainbar.w,mainbar.h,FR_WIN);
7035
7036 FONT* oldfont = font;
7037 font = get_custom_font(CFONT_GUI);
7038
7039 //Drawmode button
7040 draw_text_button(screen,drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode],vc(1),vc(14),0,true);
7041 //Compact button
7042 draw_text_button(screen,compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact", vc(1),vc(14),0,true);
7043
7044 font = oldfont;
7045
7046 d_nbmenu_proc(MSG_DRAW, &dialogs[0], 0);
7047
7048 ComboBrushPause=0;
7049
7050 SCRFIX();
7051 if(update)
7052 custom_vsync();
7053 is_refreshing = refreshing = false;
7054 9 }
7055
7056 9 static int minimap_tooltip_id = ttip_register_id();
7057
7058 void select_scr()
7059 {
7060 if(Map.getCurrMap()>=Map.getMapCount())
7061 return;
7062
7063 int32_t tempcb=ComboBrush;
7064 ComboBrush=0;
7065
7066 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
7067
7068 //scooby
7069 while(gui_mouse_b())
7070 {
7071 int32_t x=gui_mouse_x();
7072 int32_t y=gui_mouse_y();
7073
7074 int32_t ind = real_mini.rectind(x,y);
7075
7076 if(ind>=MAPSCRS)
7077 ind-=16;
7078
7079 if(ind > -1 && ind != Map.getCurrScr())
7080 {
7081 Map.setCurrScr(ind);
7082 }
7083
7084 custom_vsync();
7085 refresh(rALL);
7086 }
7087
7088 ComboBrush=tempcb;
7089 }
7090
7091 void clear_cpool()
7092 {
7093 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
7094 {
7095 pool_combos[i].clear();
7096 }
7097 pool_dirty = true;
7098 }
7099
7100 bool select_favorite()
7101 {
7102 int32_t tempcb=ComboBrush;
7103 ComboBrush=0;
7104 bool valid=false;
7105
7106 while(gui_mouse_b())
7107 {
7108 valid=false;
7109 int32_t x=gui_mouse_x();
7110
7111 if(x<favorites_list.x)
7112 x=favorites_list.x;
7113
7114 if(x>favorites_list.x+(favorites_list.w*favorites_list.xscale)-1)
7115 x=favorites_list.x+(favorites_list.w*favorites_list.xscale)-1;
7116
7117 int32_t y=gui_mouse_y();
7118
7119 if(y<favorites_list.y)
7120 y=favorites_list.y;
7121
7122 if(y>favorites_list.y+(favorites_list.h*favorites_list.yscale)-1)
7123 y=favorites_list.y+(favorites_list.h*favorites_list.yscale)-1;
7124
7125 int32_t tempc=(((y-favorites_list.y)/favorites_list.yscale)*FAVORITECOMBO_PER_ROW)+((x-favorites_list.x)/favorites_list.xscale) + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
7126
7127 if(tempc >= MAXFAVORITECOMBOS)
7128 {
7129 //Nothing, invalid
7130 }
7131 else
7132 {
7133 if(favorite_combos[tempc]!=-1)
7134 {
7135 switch(favorite_combo_modes[tempc])
7136 {
7137 case dm_alias:
7138 draw_mode = dm_alias;
7139 combo_apos = favorite_combos[tempc];
7140 break;
7141 case dm_cpool:
7142 draw_mode = dm_cpool;
7143 combo_pool_pos = favorite_combos[tempc];
7144 break;
7145 case dm_auto:
7146 draw_mode = dm_auto;
7147 combo_auto_pos = favorite_combos[tempc];
7148 break;
7149 default:
7150 draw_mode = dm_normal;
7151 Combo = favorite_combos[tempc];
7152 }
7153 if(AutoBrush)
7154 BrushWidth = BrushHeight = 1;
7155 valid=true;
7156 fix_drawing_mode_menu();
7157 }
7158 }
7159
7160 custom_vsync();
7161 refresh(rALL);
7162 }
7163
7164 ComboBrush=tempcb;
7165 return valid;
7166 }
7167
7168 void select_combo(int32_t clist)
7169 {
7170 current_combolist=clist;
7171 int32_t tempcb=ComboBrush;
7172 ComboBrush=0;
7173
7174 int autobrush_cx = -1, autobrush_cy = -1;
7175 int autobrush_first = First[current_combolist];
7176 auto& curlist = combolist[current_combolist];
7177 AutoBrushRevert = (key[KEY_ALT]||key[KEY_ALTGR]);
7178 while(gui_mouse_b())
7179 {
7180 int32_t x=gui_mouse_x();
7181
7182 if(x<curlist.x)
7183 x=curlist.x;
7184
7185 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7186 x=curlist.x+(curlist.w*curlist.xscale)-1;
7187
7188 int32_t y=gui_mouse_y();
7189
7190 if(y<curlist.y)
7191 y=curlist.y;
7192
7193 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7194 y=curlist.y+(curlist.h*curlist.yscale)-1;
7195
7196 int cx = ((x-curlist.x)/curlist.xscale), cy = ((y-curlist.y)/curlist.yscale);
7197 if(AutoBrush)
7198 {
7199 if(autobrush_cx < 0)
7200 {
7201 autobrush_cx = cx;
7202 autobrush_cy = cy;
7203 }
7204 BrushWidth = vbound(abs(autobrush_cx-cx)+1,1,16);
7205 BrushHeight = vbound(abs(autobrush_cy-cy)+1,1,11);
7206 cx = std::min(autobrush_cx,cx);
7207 cy = std::min(autobrush_cy,cy);
7208 }
7209 Combo=(cy*curlist.w)+cx+First[current_combolist];
7210 custom_vsync();
7211 refresh(rALL);
7212 if(AutoBrush) //Prevent any scrolling
7213 First[current_combolist] = autobrush_first;
7214 }
7215 if(key[KEY_ALT]||key[KEY_ALTGR])
7216 AutoBrushRevert = true;
7217 position_mouse_z(0);
7218 ComboBrush=tempcb;
7219 }
7220
7221 void select_comboa(int32_t clist)
7222 {
7223 current_comboalist=clist;
7224 int32_t tempcb=ComboBrush;
7225 ComboBrush=0;
7226 alias_cset_mod=0;
7227
7228 auto& curlist = comboaliaslist[current_comboalist];
7229 while(gui_mouse_b())
7230 {
7231 int32_t x=gui_mouse_x();
7232
7233 if(x<curlist.x)
7234 x=curlist.x;
7235
7236 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7237 x=curlist.x+(curlist.w*curlist.xscale)-1;
7238
7239 int32_t y=gui_mouse_y();
7240
7241 if(y<curlist.y)
7242 y=curlist.y;
7243
7244 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7245 y=curlist.y+(curlist.h*curlist.yscale)-1;
7246
7247 combo_apos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_alistpos[current_comboalist];
7248 custom_vsync();
7249 refresh(rALL);
7250 }
7251
7252 ComboBrush=tempcb;
7253 }
7254
7255 void select_combop(int32_t clist)
7256 {
7257 current_cpoollist=clist;
7258 int32_t tempcb=ComboBrush;
7259 ComboBrush=0;
7260
7261 auto& curlist = comboaliaslist[current_cpoollist];
7262 while(gui_mouse_b())
7263 {
7264 int32_t x=gui_mouse_x();
7265
7266 if(x<curlist.x) x=curlist.x;
7267
7268 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7269 x=curlist.x+(curlist.w*curlist.xscale)-1;
7270
7271 int32_t y=gui_mouse_y();
7272
7273 if(y<curlist.y) y=curlist.y;
7274
7275 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7276 y=curlist.y+(curlist.h*curlist.yscale)-1;
7277
7278 combo_pool_pos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_pool_listpos[current_cpoollist];
7279 custom_vsync();
7280 refresh(rALL);
7281 }
7282
7283 ComboBrush=tempcb;
7284 }
7285
7286 void select_autocombo(int32_t clist)
7287 {
7288 current_cautolist = clist;
7289 int32_t tempcb = ComboBrush;
7290 ComboBrush = 0;
7291
7292 auto& curlist = comboaliaslist[current_cautolist];
7293 while (gui_mouse_b())
7294 {
7295 int32_t x = gui_mouse_x();
7296
7297 if (x < curlist.x) x = curlist.x;
7298
7299 if (x > curlist.x + (curlist.w * curlist.xscale) - 1)
7300 x = curlist.x + (curlist.w * curlist.xscale) - 1;
7301
7302 int32_t y = gui_mouse_y();
7303
7304 if (y < curlist.y) y = curlist.y;
7305
7306 if (y > curlist.y + (curlist.h * curlist.yscale) - 1)
7307 y = curlist.y + (curlist.h * curlist.yscale) - 1;
7308
7309 combo_auto_pos = (((y - curlist.y) / curlist.yscale) * curlist.w) + ((x - curlist.x) / curlist.xscale) + combo_auto_listpos[current_cautolist];
7310 cauto_height = combo_autos[combo_auto_pos].getArg() + 1;
7311 custom_vsync();
7312 refresh(rALL);
7313 }
7314
7315 ComboBrush = tempcb;
7316 }
7317
7318 void update_combobrush()
7319 {
7320 clear_bitmap(brushbmp);
7321
7322 if(draw_mode==dm_alias)
7323 {
7324 //int32_t count=(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*(comboa_lmasktotal(combo_aliases[combo_apos].layermask));
7325 for(int32_t z=0; z<=comboa_lmasktotal(combo_aliases[combo_apos].layermask); z++)
7326 {
7327 for(int32_t y=0; y<=combo_aliases[combo_apos].height; y++)
7328 {
7329 for(int32_t x=0; x<=combo_aliases[combo_apos].width; x++)
7330 {
7331 int32_t position = ((y*(combo_aliases[combo_apos].width+1))+x)+((combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*z);
7332
7333 if(combo_aliases[combo_apos].combos[position])
7334 {
7335 if(z==0)
7336 {
7337 putcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7338 }
7339 else
7340 {
7341 overcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7342 }
7343 }
7344 }
7345 }
7346 }
7347
7348 switch(alias_origin)
7349 {
7350 case 0:
7351 //if(!(combo_aliases[combo_apos].combos[0]))
7352 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6, 6, vc(15), vc(0), -1, "x");
7353 break;
7354
7355 case 1:
7356 //if(!(combo_aliases[combo_apos].combos[combo_aliases[combo_apos].width]))
7357 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6+(combo_aliases[combo_apos].width*16), 6, vc(15), vc(0), -1, "x");
7358 break;
7359
7360 case 2:
7361 //if(!(combo_aliases[combo_apos].combos[(combo_aliases[combo_apos].width+1)*combo_aliases[combo_apos].height]))
7362 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6, 6+(combo_aliases[combo_apos].height*16), vc(15), vc(0), -1, "x");
7363 break;
7364
7365 case 3:
7366 //if(!(combo_aliases[combo_apos].combos[(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height)-1]))
7367 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), 6+(combo_aliases[combo_apos].width*16), 6+(combo_aliases[combo_apos].height*16), vc(15), vc(0), -1, "x");
7368 break;
7369 }
7370 }
7371 else if(draw_mode != dm_cpool)
7372 {
7373 int32_t cid = combobrushoverride > -1 ? combobrushoverride : Combo;
7374 if(combo_cols==false)
7375 {
7376 for(int32_t i=0; i<256; i++)
7377 {
7378 if(unsigned(cid+i) >= MAXCOMBOS) break;
7379 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7380 {
7381 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+i,CSet,Flags&(cFLAGS|cWALK),0);
7382 }
7383 }
7384 }
7385 else
7386 {
7387 int32_t c = 0;
7388
7389 for(int32_t i=0; i<256; i++)
7390 {
7391 if(unsigned(cid+c) >= MAXCOMBOS) break;
7392 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7393 {
7394 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+c,CSet,Flags&(cFLAGS|cWALK),0);
7395 }
7396
7397 if(((cid+c)&3)==3)
7398 c+=48;
7399
7400 ++c;
7401
7402 if((i%COMBOS_PER_ROW)==(COMBOS_PER_ROW-1))
7403 c-=256;
7404 }
7405 }
7406 }
7407 }
7408
7409 byte relational_source_grid[256]=
7410 {
7411 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7412 16, 16, 17, 17, 18, 18, 19, 19, 16, 16, 17, 17, 18, 18, 19, 19,
7413 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
7414 24, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25,
7415 26, 27, 26, 27, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29, 28, 29,
7416 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
7417 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
7418 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
7419 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37,
7420 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39,
7421 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
7422 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
7423 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43,
7424 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
7425 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
7426 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
7427 };
7428
7429 void draw_autocombo(int32_t pos, bool rclick, bool pressframe)
7430 {
7431 int32_t cid = Combo;
7432 int8_t cs = CSet;
7433 combo_auto &ca = combo_autos[combo_auto_pos];
7434
7435 int32_t scr = Map.getCurrScr();
7436 if (ca.valid())
7437 {
7438 switch (ca.getType())
7439 {
7440 case AUTOCOMBO_BASIC:
7441 {
7442 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7443 if (rclick)
7444 ap.erase(scr, pos);
7445 else
7446 ap.execute(scr, pos);
7447 break;
7448 }
7449 case AUTOCOMBO_Z1:
7450 {
7451 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7452 if (rclick)
7453 ap.erase(scr, pos);
7454 else
7455 ap.execute(scr, pos);
7456 break;
7457 }
7458 case AUTOCOMBO_FENCE:
7459 {
7460 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7461 if (rclick)
7462 ap.erase(scr, pos);
7463 else
7464 ap.execute(scr, pos);
7465 break;
7466 }
7467 case AUTOCOMBO_Z4:
7468 {
7469 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7470 if (rclick)
7471 ap.erase(scr, pos);
7472 else
7473 ap.execute(scr, pos);
7474 break;
7475 }
7476 case AUTOCOMBO_RELATIONAL:
7477 {
7478 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7479 if (rclick)
7480 ap.erase(scr, pos);
7481 else
7482 ap.execute(scr, pos);
7483 break;
7484 }
7485 case AUTOCOMBO_DGNCARVE:
7486 {
7487 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7488 if (rclick)
7489 ap.erase(scr, pos);
7490 else
7491 ap.execute(scr, pos);
7492 break;
7493 }
7494 case AUTOCOMBO_DOR:
7495 {
7496 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7497 if (rclick)
7498 ap.erase(scr, pos);
7499 else
7500 ap.execute(scr, pos);
7501 break;
7502 }
7503 case AUTOCOMBO_TILING:
7504 {
7505 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7506 {
7507 int32_t x = (scr % 16) * 16 + (pos % 16);
7508 int32_t y = (scr / 16) * 11 + (pos / 16);
7509 byte w = (ca.getArg() & 0xF) + 1;
7510 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7511 ca.setOffsets(x % w, y % h);
7512 }
7513 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7514 if (rclick)
7515 ap.erase(scr, pos);
7516 else
7517 ap.execute(scr, pos);
7518 break;
7519 }
7520 case AUTOCOMBO_REPLACE:
7521 {
7522 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7523 if (rclick)
7524 ap.erase(scr, pos);
7525 else
7526 ap.execute(scr, pos);
7527 break;
7528 }
7529 }
7530 }
7531 else
7532 {
7533 ca.updateValid();
7534 if(!ca.valid())
7535 InfoDialog("Notice", "The autocombo you're trying to use is invalid. Reason:"
7536 + ca.getInvalidReason()).show();
7537 }
7538 }
7539
7540 void draw_autocombo_command(int32_t pos, int32_t cmd, int32_t arg)
7541 {
7542 int32_t cid = Combo;
7543 int8_t cs = CSet;
7544 combo_auto ca = combo_autos[combo_auto_pos];
7545
7546 int32_t scr = Map.getCurrScr();
7547 if (ca.valid())
7548 {
7549 switch (ca.getType())
7550 {
7551 case AUTOCOMBO_FENCE:
7552 {
7553 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7554 ap.flip_all_connected(scr, pos, 2048);
7555 break;
7556 }
7557 case AUTOCOMBO_Z4:
7558 {
7559 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7560 switch (cmd)
7561 {
7562 case 0: // Flip
7563 ap.flip_all_connected(scr, pos, 2048);
7564 break;
7565 case 1: // Grow
7566 ap.resize_connected(scr, pos, 2048, vbound(arg, 1, 9));
7567 break;
7568 }
7569 }
7570 }
7571 }
7572 }
7573
7574 int32_t get_autocombo_floating_cid(int32_t pos, bool clicked)
7575 {
7576 combo_auto& ca = combo_autos[combo_auto_pos];
7577
7578 int32_t scr = Map.getCurrScr();
7579 int32_t cid = 0;
7580 if (ca.valid() && mousecomboposition > -1)
7581 {
7582 switch (ca.getType())
7583 {
7584 case AUTOCOMBO_BASIC:
7585 {
7586 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7587 cid = ap.get_floating_cid(scr, pos);
7588 break;
7589 }
7590
7591 case AUTOCOMBO_Z1:
7592 {
7593 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7594 cid = ap.get_floating_cid(scr, pos);
7595 break;
7596 }
7597 case AUTOCOMBO_FENCE:
7598 {
7599 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7600 cid = ap.get_floating_cid(scr, pos);
7601 break;
7602 }
7603 case AUTOCOMBO_Z4:
7604 {
7605 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7606 cid = ap.get_floating_cid(scr, pos);
7607 break;
7608 }
7609 case AUTOCOMBO_RELATIONAL:
7610 {
7611 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7612 cid = ap.get_floating_cid(scr, pos);
7613 break;
7614 }
7615 case AUTOCOMBO_DGNCARVE:
7616 {
7617 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7618 cid = ap.get_floating_cid(scr, pos);
7619 break;
7620 }
7621 case AUTOCOMBO_DOR:
7622 {
7623 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, scr, pos, &ca, cauto_height);
7624 cid = ap.get_floating_cid(scr, pos);
7625 break;
7626 }
7627 case AUTOCOMBO_TILING:
7628 {
7629 std::pair<byte, byte> offs = ca.getOffsets();
7630 if (!clicked && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7631 {
7632 int32_t x = (scr % 16) * 16 + (pos % 16);
7633 int32_t y = (scr / 16) * 11 + (pos / 16);
7634 byte w = (ca.getArg() & 0xF) + 1;
7635 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7636 offs.first = (x % w);
7637 offs.second = (y % h);
7638 }
7639 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7640 cid = ap.get_floating_cid(scr, pos);
7641 break;
7642 }
7643 case AUTOCOMBO_REPLACE:
7644 {
7645 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, scr, pos, &ca);
7646 cid = ap.get_floating_cid(scr, pos);
7647 break;
7648 }
7649 }
7650 }
7651 return cid;
7652 }
7653
7654 void change_autocombo_height(int32_t change)
7655 {
7656 bool can_change = false;
7657 if (draw_mode == dm_auto)
7658 {
7659 combo_auto ca = combo_autos[combo_auto_pos];
7660 switch (ca.getType())
7661 {
7662 case AUTOCOMBO_Z4:
7663 can_change = true;
7664 [[fallthrough]];
7665 case AUTOCOMBO_DOR:
7666 break;
7667 default:
7668 return;
7669 }
7670 }
7671 else
7672 return;
7673 int32_t x = gui_mouse_x();
7674 int32_t y = gui_mouse_y();
7675 double startx = mapscreen_x + (showedges ? (16 * mapscreensize) : 0);
7676 double starty = mapscreen_y + (showedges ? (16 * mapscreensize) : 0);
7677 int32_t startxint = mapscreen_x + (showedges ? int32_t(16 * mapscreensize) : 0);
7678 int32_t startyint = mapscreen_y + (showedges ? int32_t(16 * mapscreensize) : 0);
7679
7680 if (can_change && isinRect(x, y, startxint, startyint, int32_t(startx + (256 * mapscreensize) - 1), int32_t(starty + (176 * mapscreensize) - 1)))
7681 {
7682 Map.StartListCommand();
7683 int32_t cxstart = (x - startxint) / int32_t(16 * mapscreensize);
7684 int32_t cystart = (y - startyint) / int32_t(16 * mapscreensize);
7685 int32_t cstart = (cystart * 16) + cxstart;
7686 draw_autocombo_command(cstart, 1, cauto_height + change);
7687 Map.FinishListCommand();
7688 }
7689 cauto_height = vbound(cauto_height + change, 1, 9);
7690 }
7691
7692 void draw(bool justcset)
7693 {
7694 combo_pool const& pool = combo_pools[combo_pool_pos];
7695 if(draw_mode == dm_cpool && !pool.valid())
7696 return;
7697 saved=false;
7698 int32_t drawmap, drawscr;
7699
7700 if(CurrentLayer==0)
7701 {
7702 drawmap=Map.getCurrMap();
7703 drawscr=Map.getCurrScr();
7704 }
7705 else
7706 {
7707 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
7708 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
7709 }
7710
7711 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
7712 if(!draw_mapscr) return;
7713 if(!(draw_mapscr->valid&mVALID))
7714 {
7715 Map.CurrScr()->valid|=mVALID;
7716 draw_mapscr->valid|=mVALID;
7717 Map.setcolor(Color);
7718 }
7719
7720 refresh(rMAP+rSCRMAP);
7721 int32_t lastpos = -1;
7722
7723 std::shared_ptr<tile_grid_draw_command> dungeon_draw_cmd;
7724 if (draw_mode == dm_relational || draw_mode == dm_dungeon)
7725 {
7726 dungeon_draw_cmd = std::make_shared<tile_grid_draw_command>();
7727 util::copy_2d_array<byte, 15, 20>(relational_tile_grid, dungeon_draw_cmd->prev_tile_grid);
7728 }
7729
7730 Map.StartListCommand();
7731 bool pressframe = true;
7732 while(gui_mouse_b())
7733 {
7734 int32_t x=gui_mouse_x();
7735 int32_t y=gui_mouse_y();
7736 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
7737 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
7738 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
7739 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
7740
7741 if(isinRect(x,y,startxint,startyint,int32_t(startx+(256*mapscreensize)-1),int32_t(starty+(176*mapscreensize)-1)))
7742 {
7743 int32_t cxstart=(x-startxint)/int32_t(16*mapscreensize);
7744 int32_t cystart=(y-startyint)/int32_t(16*mapscreensize);
7745 int32_t cstart=(cystart*16)+cxstart;
7746 if (pressframe)
7747 {
7748 lastpos = cstart;
7749 }
7750 else if(cstart == lastpos)
7751 {
7752 custom_vsync();
7753 refresh(rALL);
7754 continue;
7755 }
7756 else if(draw_mode == dm_auto)
7757 {
7758 if (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE || combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4)
7759 {
7760 bool did_diag = false;
7761 // Don't allow moving the brush at anything but cardinal directions while in these modes
7762 switch (cstart - lastpos)
7763 {
7764 case -1:
7765 case 1:
7766 case -16:
7767 case 16:
7768 break;
7769 default:
7770 did_diag = true;
7771 }
7772 if (did_diag)
7773 {
7774 int32_t oldx = lastpos % 16;
7775 int32_t oldy = lastpos / 16;
7776 int32_t cx = (oldx * 16 * mapscreensize) + 8;
7777 int32_t cy = (oldy * 16 * mapscreensize) + 8;
7778 int32_t nx = x - startxint;
7779 int32_t ny = y - startyint;
7780 if (std::abs(nx - cx) < std::abs(ny - cy))
7781 {
7782 oldy = vbound(oldy + ((ny - cy) < 0 ? -1 : 1), 0, 11);
7783 }
7784 else
7785 {
7786 oldx = vbound(oldx + ((nx - cx) < 0 ? -1 : 1), 0, 15);
7787 }
7788 cstart = (oldy * 16) + oldx;
7789 }
7790 }
7791 }
7792 lastpos = cstart;
7793
7794 switch(draw_mode)
7795 {
7796 case dm_normal:
7797 {
7798 int32_t cc=Combo;
7799
7800 if(!combo_cols)
7801 {
7802 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7803 {
7804 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7805 {
7806 int32_t c=cstart+(cy*16)+cx;
7807 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : (cc + cx), CSet);
7808 }
7809
7810 cc+=20;
7811 }
7812 }
7813 else
7814 {
7815 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7816 {
7817 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7818 {
7819 int32_t c=cstart+(cy*16)+cx;
7820 cc=Combo + cx + cy*4;
7821 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : cc, CSet);
7822 }
7823 }
7824 }
7825
7826 update_combobrush();
7827 }
7828 break;
7829 case dm_cpool:
7830 {
7831 int32_t cid = Combo;
7832 int8_t cs = CSet;
7833 pool.pick(cid,cs);
7834
7835 if(!combo_cols)
7836 {
7837 auto cid2 = cid;
7838 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7839 {
7840 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7841 {
7842 int32_t c=cstart+(cy*16)+cx;
7843 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : (cid2 + cx), cs);
7844 }
7845
7846 cid2+=20;
7847 }
7848 }
7849 else
7850 {
7851 for(int32_t cy=0; cy+cystart<11&&cy<BrushHeight; cy++)
7852 {
7853 for(int32_t cx=0; cx+cxstart<16&&cx<BrushWidth; cx++)
7854 {
7855 int32_t c=cstart+(cy*16)+cx;
7856 auto cid2=cid + cx + cy*4;
7857 Map.DoSetComboCommand(drawmap, drawscr, c, justcset ? -1 : cid2, cs);
7858 }
7859 }
7860 }
7861
7862 update_combobrush();
7863 }
7864 break;
7865
7866 case dm_relational:
7867 {
7868 int32_t c2,c3;
7869 int32_t cx, cy, cx2, cy2;
7870 cy=cstart>>4;
7871 cx=cstart&15;
7872
7873 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
7874 {
7875 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=1;
7876 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo+47, CSet);
7877 }
7878 else
7879 {
7880 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=0;
7881 }
7882
7883 for(int32_t y2=-1; y2<2; ++y2)
7884 {
7885 cy2=cy+y2;
7886
7887 if((cy2>11)||(cy2<0))
7888 {
7889 continue;
7890 }
7891
7892 for(int32_t x2=-1; x2<2; ++x2)
7893 {
7894 cx2=cx+x2;
7895
7896 if((cx2>15)||(cx2<0))
7897 {
7898 continue;
7899 }
7900
7901 c2=cstart+(y2*16)+x2;
7902 c3=((relational_tile_grid[((cy2-1)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<0)+
7903 ((relational_tile_grid[((cy2-1)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<1)+
7904 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<2)+
7905 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<3)+
7906 ((relational_tile_grid[((cy2)+rtgyo)][(cx2+1)+rtgxo]?1:0)<<4)+
7907 ((relational_tile_grid[((cy2-1)+rtgyo)][(cx2)+rtgxo]?1:0)<<5)+
7908 ((relational_tile_grid[((cy2)+rtgyo)][(cx2-1)+rtgxo]?1:0)<<6)+
7909 ((relational_tile_grid[((cy2+1)+rtgyo)][(cx2)+rtgxo]?1:0)<<7);
7910
7911 if(relational_tile_grid[((c2>>4)+rtgyo)][(c2&15)+rtgxo]==0)
7912 {
7913 Map.DoSetComboCommand(drawmap, drawscr, c2, Combo+relational_source_grid[c3], CSet);
7914 }
7915 }
7916 }
7917 }
7918 break;
7919
7920 case dm_dungeon:
7921 {
7922 int32_t c2,c3,c4;
7923 int32_t cx, cy, cx2, cy2;
7924 cy=cstart>>4;
7925 cx=cstart&15;
7926
7927 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
7928 {
7929 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=0;
7930
7931 for(int32_t y2=-1; y2<2; ++y2)
7932 {
7933 cy2=cy+y2;
7934
7935 if((cy2>11)||(cy2<0))
7936 {
7937 continue;
7938 }
7939
7940 for(int32_t x2=-1; x2<2; ++x2)
7941 {
7942 cx2=cx+x2;
7943
7944 if((cx2>15)||(cx2<0))
7945 {
7946 continue;
7947 }
7948
7949 if(relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]!=0)
7950 {
7951 relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]=1;
7952 };
7953 }
7954 }
7955
7956 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo, CSet);
7957 }
7958 else
7959 {
7960 relational_tile_grid[(cy+rtgyo)][cx+rtgxo]=2;
7961
7962 for(int32_t y2=-1; y2<2; ++y2)
7963 {
7964 cy2=cy+y2;
7965
7966 if((cy2>11)||(cy2<0))
7967 {
7968 continue;
7969 }
7970
7971 for(int32_t x2=-1; x2<2; ++x2)
7972 {
7973 cx2=cx+x2;
7974
7975 if((cx2>15)||(cx2<0))
7976 {
7977 continue;
7978 }
7979
7980 if(relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]==0)
7981 {
7982 relational_tile_grid[(cy2+rtgyo)][cx2+rtgxo]=1;
7983 };
7984 }
7985 }
7986
7987 Map.DoSetComboCommand(drawmap, drawscr, cstart, Combo+48+47, CSet);
7988 }
7989
7990 for(int32_t y2=0; y2<11; ++y2)
7991 {
7992 for(int32_t x2=0; x2<16; ++x2)
7993 {
7994 c2=(y2*16)+x2;
7995 c4=relational_tile_grid[((y2)+rtgyo)][(x2)+rtgxo];
7996 c3=(((relational_tile_grid[((y2-1)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<0)+
7997 (((relational_tile_grid[((y2-1)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<1)+
7998 (((relational_tile_grid[((y2+1)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<2)+
7999 (((relational_tile_grid[((y2+1)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<3)+
8000 (((relational_tile_grid[((y2)+rtgyo)][(x2+1)+rtgxo]>c4)?1:0)<<4)+
8001 (((relational_tile_grid[((y2-1)+rtgyo)][(x2)+rtgxo]>c4)?1:0)<<5)+
8002 (((relational_tile_grid[((y2)+rtgyo)][(x2-1)+rtgxo]>c4)?1:0)<<6)+
8003 (((relational_tile_grid[((y2+1)+rtgyo)][(x2)+rtgxo]>c4)?1:0)<<7);
8004
8005 if(relational_tile_grid[(y2+rtgyo)][x2+rtgxo]<2)
8006 {
8007 Map.DoSetComboCommand(drawmap, drawscr, c2, Combo+relational_source_grid[c3]+(48*c4), CSet);
8008 }
8009 }
8010 }
8011 }
8012 break;
8013
8014 case dm_alias:
8015 {
8016 combo_alias *combo = &combo_aliases[combo_apos];
8017 if(!combo->layermask)
8018 {
8019 int32_t ox=0, oy=0;
8020
8021 switch(alias_origin)
8022 {
8023 case 0:
8024 ox=0;
8025 oy=0;
8026 break;
8027
8028 case 1:
8029 ox=(combo->width);
8030 oy=0;
8031 break;
8032
8033 case 2:
8034 ox=0;
8035 oy=(combo->height);
8036 break;
8037
8038 case 3:
8039 ox=(combo->width);
8040 oy=(combo->height);
8041 break;
8042 }
8043
8044 for(int32_t cy=0; cy-oy+cystart<11&&cy<=combo->height; cy++)
8045 {
8046 for(int32_t cx=0; cx-ox+cxstart<16&&cx<=combo->width; cx++)
8047 {
8048 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8049 {
8050 int32_t c=cstart+((cy-oy)*16)+cx-ox;
8051 int32_t p=(cy*(combo->width+1))+cx;
8052
8053 if(combo->combos[p])
8054 {
8055 Map.DoSetComboCommand(drawmap, drawscr, c, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8056 }
8057 }
8058 }
8059 }
8060 }
8061 else
8062 {
8063 int32_t amap=0, ascr=0;
8064 int32_t lcheck = 1;
8065 int32_t laypos = 0;
8066 int32_t ox=0, oy=0;
8067
8068 switch(alias_origin)
8069 {
8070 case 0:
8071 ox=0;
8072 oy=0;
8073 break;
8074
8075 case 1:
8076 ox=(combo->width);
8077 oy=0;
8078 break;
8079
8080 case 2:
8081 ox=0;
8082 oy=(combo->height);
8083 break;
8084
8085 case 3:
8086 ox=(combo->width);
8087 oy=(combo->height);
8088 break;
8089 }
8090
8091 for(int32_t cz=0; cz<7; cz++, lcheck<<=1)
8092 {
8093 if(!cz)
8094 {
8095 amap = Map.getCurrMap();
8096 ascr = Map.getCurrScr();
8097 }
8098 else
8099 {
8100 if(cz==1) lcheck>>=1;
8101
8102 if(combo->layermask&lcheck)
8103 {
8104 amap = Map.CurrScr()->layermap[cz-1]-1;
8105 ascr = Map.CurrScr()->layerscreen[cz-1];
8106 mapscr* mapscr_ptr = Map.AbsoluteScr(amap, ascr);
8107 if(mapscr_ptr)
8108 mapscr_ptr->valid |= mVALID;
8109 laypos++;
8110 }
8111 }
8112
8113 for(int32_t cy=0; cy-oy+cystart<11&&cy<=combo->height; cy++)
8114 {
8115 for(int32_t cx=0; cx-ox+cxstart<16&&cx<=combo->width; cx++)
8116 {
8117 if((!cz)||/*(Map.CurrScr()->layermap[cz>0?cz-1:0])*/amap>=0)
8118 {
8119 if((cz==0)||(combo->layermask&lcheck))
8120 {
8121 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8122 {
8123 int32_t c=cstart+((cy-oy)*16)+cx-ox;
8124 int32_t p=((cy*(combo->width+1))+cx)+((combo->width+1)*(combo->height+1)*laypos);
8125
8126 if((combo->combos[p])&&(amap>=0))
8127 {
8128 Map.DoSetComboCommand(amap, ascr, c, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8129 }
8130 }
8131 }
8132 }
8133 }
8134 }
8135 }
8136 }
8137
8138 break;
8139 }
8140
8141 case dm_auto:
8142 {
8143 draw_autocombo(cstart, gui_mouse_b() & 2, pressframe);
8144
8145 combobrushoverride = get_autocombo_floating_cid(cstart, true);
8146 update_combobrush();
8147 }
8148 }
8149 }
8150 pressframe = false;
8151
8152 custom_vsync();
8153 refresh(rALL);
8154 }
8155
8156 if (dungeon_draw_cmd)
8157 {
8158 util::copy_2d_array<byte, 15, 20>(relational_tile_grid, dungeon_draw_cmd->tile_grid);
8159 Map.ExecuteCommand(dungeon_draw_cmd, true);
8160 }
8161 Map.FinishListCommand();
8162 if(AutoBrushRevert)
8163 {
8164 AutoBrushRevert = false;
8165 BrushWidth = 1;
8166 BrushHeight = 1;
8167 }
8168 }
8169
8170 void replace(int32_t c)
8171 {
8172 int32_t cid = Combo;
8173 int8_t cs = CSet;
8174 combo_pool const& pool = combo_pools[combo_pool_pos];
8175 if(draw_mode == dm_cpool && !pool.valid())
8176 return;
8177
8178 saved=false;
8179 int32_t drawmap, drawscr;
8180
8181 if(CurrentLayer==0)
8182 {
8183 drawmap=Map.getCurrMap();
8184 drawscr=Map.getCurrScr();
8185 }
8186 else
8187 {
8188 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
8189 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
8190 }
8191 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
8192 if(!draw_mapscr) return;
8193
8194 int32_t targetcombo = draw_mapscr->data[c];
8195 int32_t targetcset = draw_mapscr->cset[c];
8196
8197 Map.StartListCommand();
8198 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
8199 {
8200 for(int32_t i=0; i<176; i++)
8201 {
8202 if((draw_mapscr->cset[i])==targetcset)
8203 {
8204 if(draw_mode == dm_cpool)
8205 pool.pick(cid,cs);
8206 Map.DoSetComboCommand(drawmap, drawscr, i, -1, cs);
8207 }
8208 }
8209 }
8210 else
8211 {
8212 for(int32_t i=0; i<176; i++)
8213 {
8214 if(((draw_mapscr->data[i])==targetcombo) &&
8215 ((draw_mapscr->cset[i])==targetcset))
8216 {
8217 if(draw_mode == dm_cpool)
8218 pool.pick(cid,cs);
8219 Map.DoSetComboCommand(drawmap, drawscr, i, cid, cs);
8220 }
8221 }
8222 }
8223 Map.FinishListCommand();
8224
8225 refresh(rMAP);
8226 }
8227
8228 void draw_block(int32_t start,int32_t w,int32_t h)
8229 {
8230 int32_t cid = Combo;
8231 int8_t cs = CSet;
8232 if(draw_mode == dm_cpool)
8233 {
8234 combo_pool const& pool = combo_pools[combo_pool_pos];
8235 if(!pool.pick(cid,cs)) return;
8236 }
8237 saved=false;
8238 int32_t drawmap, drawscr;
8239
8240 if(CurrentLayer==0)
8241 {
8242 drawmap=Map.getCurrMap();
8243 drawscr=Map.getCurrScr();
8244 }
8245 else
8246 {
8247 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
8248 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
8249 }
8250 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
8251 if(!draw_mapscr) return;
8252
8253 if(!(draw_mapscr->valid&mVALID))
8254 {
8255 Map.CurrScr()->valid|=mVALID;
8256 draw_mapscr->valid|=mVALID;
8257 Map.setcolor(Color);
8258 }
8259
8260 Map.StartListCommand();
8261 for(int32_t y=0; y<h && (y<<4)+start < 176; y++)
8262 for(int32_t x=0; x<w && (start&15)+x < 16; x++)
8263 {
8264 Map.DoSetComboCommand(drawmap, drawscr, start+(y<<4)+x, cid+(y*4)+x, cs);
8265 }
8266
8267 Map.FinishListCommand();
8268 refresh(rMAP+rSCRMAP);
8269 }
8270
8271 static void fill(int32_t map, int32_t screen_index, mapscr* fillscr, int32_t targetcombo, int32_t targetcset, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal, bool only_cset, bool* filled_combos)
8272 {
8273 bool rclick = gui_mouse_b() & 2;
8274 bool ignored_combo = false;
8275
8276 if (filled_combos[(sy << 4) + sx])
8277 return;
8278
8279 if (draw_mode == dm_auto)
8280 {
8281 combo_auto const& cauto = combo_autos[combo_auto_pos];
8282 ignored_combo = cauto.isIgnoredCombo((fillscr->data[((sy << 4) + sx)]));
8283 if (rclick)
8284 {
8285 if (cauto.containsCombo(targetcombo))
8286 {
8287 if (!cauto.containsCombo(fillscr->data[((sy << 4) + sx)]))
8288 return;
8289 if (cauto.getType() == AUTOCOMBO_REPLACE && ignored_combo)
8290 return;
8291 }
8292 else
8293 return;
8294 }
8295 else
8296 {
8297 if ((fillscr->data[((sy<<4)+sx)])!=targetcombo && !ignored_combo)
8298 return;
8299 if (cauto.getType() == AUTOCOMBO_REPLACE && !ignored_combo)
8300 return;
8301 }
8302
8303 if((fillscr->cset[((sy<<4)+sx)])!=targetcset && !ignored_combo)
8304 return;
8305 }
8306 else
8307 {
8308 if(!only_cset)
8309 {
8310 if((fillscr->data[((sy<<4)+sx)])!=targetcombo)
8311 return;
8312 }
8313
8314 if((fillscr->cset[((sy<<4)+sx)])!=targetcset)
8315 return;
8316 }
8317
8318 int32_t cid = Combo;
8319 int8_t cs = CSet;
8320 if(draw_mode == dm_cpool)
8321 {
8322 combo_pool const& pool = combo_pools[combo_pool_pos];
8323 if(!pool.pick(cid,cs)) return;
8324 }
8325 else if (draw_mode == dm_auto)
8326 {
8327 combo_auto const& cauto = combo_autos[combo_auto_pos];
8328 if (!cauto.valid())
8329 return;
8330 if (!rclick && (cauto.containsCombo(targetcombo) && !ignored_combo))
8331 return;
8332 if (rclick && cauto.getEraseCombo() == targetcombo)
8333 return;
8334 }
8335
8336 filled_combos[(sy << 4) + sx] = true;
8337
8338 if (draw_mode == dm_auto)
8339 {
8340 draw_autocombo((sy << 4) + sx, rclick);
8341 }
8342 else
8343 Map.DoSetComboCommand(map, screen_index, (sy<<4)+sx, only_cset ? -1 : cid, cs);
8344
8345 if((sy>0) && (dir!=down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx)]&0x7FF)==target))
8346 fill(map, screen_index, fillscr, targetcombo, targetcset, sx, sy-1, up, diagonal, only_cset, filled_combos);
8347
8348 if((sy<10) && (dir!=up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx)]&0x7FF)==target))
8349 fill(map, screen_index, fillscr, targetcombo, targetcset, sx, sy+1, down, diagonal, only_cset, filled_combos);
8350
8351 if((sx>0) && (dir!=right)) // && ((Map.CurrScr()->data[((sy<<4)+sx-1)]&0x7FF)==target))
8352 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy, left, diagonal, only_cset, filled_combos);
8353
8354 if((sx<15) && (dir!=left)) // && ((Map.CurrScr()->data[((sy<<4)+sx+1)]&0x7FF)==target))
8355 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy, right, diagonal, only_cset, filled_combos);
8356
8357 if(diagonal==1)
8358 {
8359 if((sy>0) && (sx>0) && (dir!=r_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx-1)]&0x7FF)==target))
8360 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy-1, l_up, diagonal, only_cset, filled_combos);
8361
8362 if((sy<10) && (sx<15) && (dir!=l_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx+1)]&0x7FF)==target))
8363 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy+1, r_down, diagonal, only_cset, filled_combos);
8364
8365 if((sx>0) && (sy<10) && (dir!=r_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx-1)]&0x7FF)==target))
8366 fill(map, screen_index, fillscr, targetcombo, targetcset, sx-1, sy+1, l_down, diagonal, only_cset, filled_combos);
8367
8368 if((sx<15) && (sy>0) && (dir!=l_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx+1)]&0x7FF)==target))
8369 fill(map, screen_index, fillscr, targetcombo, targetcset, sx+1, sy-1, r_up, diagonal, only_cset, filled_combos);
8370 }
8371 }
8372
8373 static void fill_flag(int32_t map, int32_t screen_index, mapscr* fillscr, int32_t targetflag, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal)
8374 {
8375 if((fillscr->sflag[((sy<<4)+sx)])!=targetflag)
8376 return;
8377
8378 Map.DoSetFlagCommand(map, screen_index, (sy<<4)+sx, Flag);
8379
8380 if((sy>0) && (dir!=down))
8381 fill_flag(map, screen_index, fillscr, targetflag, sx, sy-1, up, diagonal);
8382
8383 if((sy<10) && (dir!=up))
8384 fill_flag(map, screen_index, fillscr, targetflag, sx, sy+1, down, diagonal);
8385
8386 if((sx>0) && (dir!=right))
8387 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy, left, diagonal);
8388
8389 if((sx<15) && (dir!=left))
8390 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy, right, diagonal);
8391
8392 if(diagonal==1)
8393 {
8394 if((sy>0) && (sx>0) && (dir!=r_down))
8395 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy-1, l_up, diagonal);
8396
8397 if((sy<10) && (sx<15) && (dir!=l_up))
8398 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy+1, r_down, diagonal);
8399
8400 if((sx>0) && (sy<10) && (dir!=r_up))
8401 fill_flag(map, screen_index, fillscr, targetflag, sx-1, sy+1, l_down, diagonal);
8402
8403 if((sx<15) && (sy>0) && (dir!=l_down))
8404 fill_flag(map, screen_index, fillscr, targetflag, sx+1, sy-1, r_up, diagonal);
8405 }
8406
8407 }
8408
8409 static void fill2(mapscr* fillscr, int32_t targetcombo, int32_t targetcset, int32_t sx, int32_t sy, int32_t dir, int32_t diagonal, bool only_cset)
8410 {
8411 if(!only_cset)
8412 {
8413 if((fillscr->data[((sy<<4)+sx)])==targetcombo)
8414 return;
8415 }
8416
8417 if((fillscr->cset[((sy<<4)+sx)])==targetcset)
8418 return;
8419
8420 int32_t cid = Combo;
8421 int8_t cs = CSet;
8422 if(draw_mode == dm_cpool)
8423 {
8424 combo_pool const& pool = combo_pools[combo_pool_pos];
8425 if(!pool.pick(cid,cs)) return;
8426 }
8427
8428 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (sy<<4)+sx, only_cset ? -1 : cid, cs);
8429
8430 if((sy>0) && (dir!=down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx)]&0x7FF)!=target))
8431 fill2(fillscr, targetcombo, targetcset, sx, sy-1, up, diagonal, only_cset);
8432
8433 if((sy<10) && (dir!=up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx)]&0x7FF)!=target))
8434 fill2(fillscr, targetcombo, targetcset, sx, sy+1, down, diagonal, only_cset);
8435
8436 if((sx>0) && (dir!=right)) // && ((Map.CurrScr()->data[((sy<<4)+sx-1)]&0x7FF)!=target))
8437 fill2(fillscr, targetcombo, targetcset, sx-1, sy, left, diagonal, only_cset);
8438
8439 if((sx<15) && (dir!=left)) // && ((Map.CurrScr()->data[((sy<<4)+sx+1)]&0x7FF)!=target))
8440 fill2(fillscr, targetcombo, targetcset, sx+1, sy, right, diagonal, only_cset);
8441
8442 if(diagonal==1)
8443 {
8444 if((sy>0) && (sx>0) && (dir!=r_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx-1)]&0x7FF)!=target))
8445 fill2(fillscr, targetcombo, targetcset, sx-1, sy-1, l_up, diagonal, only_cset);
8446
8447 if((sy<10) && (sx<15) && (dir!=l_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx+1)]&0x7FF)!=target))
8448 fill2(fillscr, targetcombo, targetcset, sx+1, sy+1, r_down, diagonal, only_cset);
8449
8450 if((sx>0) && (sy<10) && (dir!=r_up)) // && ((Map.CurrScr()->data[(((sy+1)<<4)+sx-1)]&0x7FF)!=target))
8451 fill2(fillscr, targetcombo, targetcset, sx-1, sy+1, l_down, diagonal, only_cset);
8452
8453 if((sx<15) && (sy>0) && (dir!=l_down)) // && ((Map.CurrScr()->data[(((sy-1)<<4)+sx+1)]&0x7FF)!=target))
8454 fill2(fillscr, targetcombo, targetcset, sx+1, sy-1, r_up, diagonal, only_cset);
8455 }
8456 }
8457
8458
8459 #define SNAP_NONE 0xFF
8460 #define SNAP_HALF 0xF8
8461 #define SNAP_WHOLE 0xF0
8462
8463 static void doxypos(byte &px2, byte &py2, int32_t color, int32_t mask,
8464 int32_t shiftmask, bool immediately, int32_t cursoroffx,
8465 int32_t cursoroffy, int32_t iconw, int32_t iconh)
8466 {
8467 int32_t tempcb=ComboBrush;
8468 ComboBrush=0;
8469 MouseSprite::set(ZQM_POINT_BOX);
8470
8471 int32_t oldpx=px2, oldpy=py2;
8472 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
8473 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
8474 showxypos_x=px2;
8475 showxypos_y=py2;
8476 showxypos_w=iconw;
8477 showxypos_h=iconh;
8478 showxypos_color=vc(color);
8479 showxypos_icon=!showxypos_dummy;
8480 bool canedit=false;
8481 bool done=false;
8482
8483 clear_tooltip();
8484
8485 while(!done && (!(gui_mouse_b()&2) || immediately))
8486 {
8487 int32_t x=gui_mouse_x();
8488 int32_t y=gui_mouse_y();
8489
8490 if(!gui_mouse_b() || immediately)
8491 {
8492 canedit=true;
8493 }
8494
8495 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,(startxint+(256*mapscreensize)-1),(startyint+(176*mapscreensize)-1)))
8496 {
8497 set_mouse_range(startxint,startyint,int32_t(startxint+(256*mapscreensize)-1),int32_t(startyint+(176*mapscreensize)-1));
8498
8499 while(gui_mouse_b()==1)
8500 {
8501 x=int32_t((gui_mouse_x()-startxint)/mapscreensize)-cursoroffx;
8502 y=int32_t((gui_mouse_y()-startyint)/mapscreensize)-cursoroffy;
8503 showxypos_cursor_icon=true;
8504 showxypos_cursor_color = showxypos_color;
8505 auto _mask = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shiftmask : mask;
8506 showxypos_cursor_x=x&_mask;
8507 showxypos_cursor_y=y&_mask;
8508 custom_vsync();
8509 refresh(rALL | rNOCURSOR);
8510 int32_t xpos[2], ypos[2];
8511 int32_t x1,y1,x2,y2;
8512
8513 char b1[200] = {0};
8514 char b2[200] = {0};
8515 if(showxypos_dummy)
8516 strcpy(b1, "DUMMY MEASURING");
8517 else sprintf(b1, "%d %d",oldpx,oldpy);
8518 sprintf(b2, "%d %d (%d %d)",x,y,showxypos_cursor_x,showxypos_cursor_y);
8519
8520 int len[2] = {text_length(font,b1),text_length(font,b2)};
8521
8522 if(is_compact)
8523 {
8524 xpos[0] = 4;
8525 ypos[0] = layer_panel.y - 21;
8526 xpos[1] = xpos[0];
8527 ypos[1] = ypos[0]+10;
8528 }
8529 else
8530 {
8531 xpos[0] = 450;
8532 ypos[0] = 405;
8533 xpos[1] = xpos[0];
8534 ypos[1] = ypos[0]+10;
8535 }
8536
8537 x1 = xpos[0];
8538 y1 = ypos[0];
8539 x2 = xpos[0];
8540 y2 = ypos[0];
8541 for(auto q = 0; q < 2; ++q)
8542 {
8543 if(xpos[q] < x1)
8544 x1 = xpos[q];
8545 if(ypos[q] < y1)
8546 y1 = ypos[q];
8547 if(ypos[q] > y2)
8548 y2 = ypos[q];
8549 if(xpos[q] + len[q] > x2)
8550 x2 = xpos[q] + len[q];
8551 }
8552 x1 -= 4;
8553 y1 -= 2;
8554 y2 += text_height(font)+2;
8555
8556 auto minx = zc_min(xpos[0],xpos[1]);
8557 auto miny = zc_min(ypos[0],ypos[1]);
8558 rectfill(screen,x1,y1,x2,y2,vc(0));
8559 textprintf_ex(screen,font,xpos[0],ypos[0],vc(15),vc(0),"%s",b1);
8560 textprintf_ex(screen,font,xpos[1],ypos[1],vc(15),vc(0),"%s",b2);
8561 update_hw_screen();
8562 }
8563
8564 if(gui_mouse_b()==0)
8565 {
8566 auto _mask = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shiftmask : mask;
8567 px2=byte(vbound(x,0,255)&_mask);
8568 py2=byte(vbound(y,0,255)&_mask);
8569 }
8570
8571 set_mouse_range(0,0,zq_screen_w-1,zq_screen_h-1);
8572 done=true;
8573 }
8574
8575 if(keypressed())
8576 {
8577 switch(readkey()>>8)
8578 {
8579 case KEY_ESC:
8580 case KEY_ENTER:
8581 goto finished;
8582 }
8583 }
8584
8585 custom_vsync();
8586 refresh(rALL | rNOCURSOR);
8587 }
8588
8589 finished:
8590 MouseSprite::set(ZQM_NORMAL);
8591 refresh(rMAP+rMENU);
8592
8593 while(gui_mouse_b())
8594 {
8595 /* do nothing */
8596 rest(1);
8597 }
8598
8599 showxypos_x=-1000;
8600 showxypos_y=-1000;
8601 showxypos_color=-1000;
8602 showxypos_ffc=-1000;
8603 showxypos_icon=false;
8604 showxypos_cursor_x=-1000;
8605 showxypos_cursor_y=-1000;
8606 showxypos_cursor_icon=false;
8607 showxypos_cursor_color=-1000;
8608 showxypos_dummy=false;
8609
8610 if(px2!=oldpx||py2!=oldpy)
8611 {
8612 saved=false;
8613 }
8614
8615 ComboBrush=tempcb;
8616 }
8617 static void doxypos(byte &px2,byte &py2,int32_t color,int32_t mask,int32_t shiftmask = 0)
8618 {
8619 doxypos(px2,py2,color,mask,shiftmask ? shiftmask : mask,false,0,0,16,16);
8620 }
8621
8622 bool placing_flags = false;
8623 void doflags()
8624 {
8625 placing_flags = true;
8626 int of=Flags;
8627 Flags=cFLAGS;
8628 refresh(rMAP | rNOCURSOR);
8629
8630 bool canedit=false;
8631 bool didShift = false;
8632 int tFlag = Flag;
8633 while(!(gui_mouse_b()&2) && !handle_close_btn_quit())
8634 {
8635 int x=gui_mouse_x();
8636 int y=gui_mouse_y();
8637 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
8638 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
8639 int startxint=mapscreen_x+(showedges?int(16*mapscreensize):0);
8640 int startyint=mapscreen_y+(showedges?int(16*mapscreensize):0);
8641 int cx=(x-startxint)/int(16*mapscreensize);
8642 int cy=(y-startyint)/int(16*mapscreensize);
8643 int c=(cy*16)+cx;
8644
8645 if(!gui_mouse_b())
8646 canedit=true;
8647 bool shift = key[KEY_LSHIFT] || key[KEY_RSHIFT];
8648 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,int(startx+(256*mapscreensize)-1),int(starty+(176*mapscreensize)-1)))
8649 {
8650 mapscr* cur_scr = (CurrentLayer
8651 ? &(TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS
8652 +(Map.CurrScr()->layerscreen[CurrentLayer-1])])
8653 : Map.CurrScr());
8654 if(key[KEY_ALT]||key[KEY_ALTGR])
8655 Flag = cur_scr->sflag[c];
8656 else
8657 {
8658 saved=false;
8659 int tflag = Flag;
8660 if(shift)
8661 Flag = mfNONE;
8662 if(CurrentLayer!=0)
8663 {
8664 // Notify if they are using a flag that doesn't work on this layer.
8665 if(!skipLayerWarning && ((Flag >= mfTRAP_H && Flag < mfPUSHD) || (Flag == mfFAIRY) || (Flag == mfMAGICFAIRY)
8666 || (Flag == mfALLFAIRY) || (Flag == mfRAFT) || (Flag == mfRAFT_BRANCH)
8667 || (Flag == mfDIVE_ITEM) || (Flag == mfARMOS_SECRET) || (Flag == mfNOENEMY)
8668 || (Flag == mfZELDA)))
8669 {
8670 InfoDialog("Notice","You are currently working on layer "
8671 +to_string(CurrentLayer)
8672 +". This combo flag does not function on layers above '0'.").show();
8673 }
8674 if(!skipLayerWarning && CurrentLayer > 2 &&
8675 ((Flag == mfBLOCKHOLE) || (Flag >= mfPUSHD && Flag < mfNOBLOCKS)
8676 || (Flag == mfPUSHUD) || (Flag == mfPUSH4)))
8677 {
8678 InfoDialog("Notice","You are currently working on layer "
8679 +to_string(CurrentLayer)
8680 +". This combo flag does not function on layers above '2'.").show();
8681 }
8682 }
8683 if(CHECK_CTRL_CMD)
8684 {
8685 switch(fill_type)
8686 {
8687 case 0:
8688 flood_flag();
8689 break;
8690
8691 case 1:
8692 case 3:
8693 fill_4_flag();
8694 break;
8695
8696 case 2:
8697 case 4:
8698 fill_8_flag();
8699 break;
8700 }
8701 }
8702 else
8703 {
8704 int map = CurrentLayer ? Map.CurrScr()->layermap[CurrentLayer-1]-1 : Map.getCurrMap();
8705 int scr = CurrentLayer ? Map.CurrScr()->layerscreen[CurrentLayer-1] : Map.getCurrScr();
8706 Map.DoSetFlagCommand(map, scr, c, Flag);
8707 }
8708 if(!(cur_scr->valid&mVALID))
8709 {
8710 Map.CurrScr()->valid|=mVALID;
8711 cur_scr->valid|=mVALID;
8712 Map.setcolor(Color);
8713 }
8714 Flag = tflag;
8715 }
8716 }
8717
8718 if(mouse_z)
8719 {
8720 for(int i=0; i<abs(mouse_z); ++i)
8721 {
8722 if(mouse_z>0)
8723 onIncreaseFlag();
8724 else
8725 onDecreaseFlag();
8726 }
8727
8728 position_mouse_z(0);
8729 }
8730
8731 if(keypressed())
8732 {
8733 int k = readkey();
8734 switch(k>>8)
8735 {
8736 case KEY_ESC:
8737 case KEY_ENTER:
8738 goto finished;
8739 }
8740 object_message(dialogs+1, MSG_XCHAR, k);
8741 Flags=cFLAGS;
8742 }
8743
8744 MouseSprite::set(ZQM_FLAG_0+(shift?0:Flag%16));
8745
8746 refresh(rALL | rCLEAR | rNOCURSOR);
8747 custom_vsync();
8748 }
8749
8750 finished:
8751 Flags=of;
8752 placing_flags = false;
8753 MouseSprite::set(ZQM_NORMAL);
8754 refresh(rMAP+rMENU);
8755
8756 while(gui_mouse_b())
8757 {
8758 /* do nothing */
8759 rest(1);
8760 }
8761 }
8762
8763 // Drag FFCs around
8764 void moveffc(int32_t i, int32_t cx, int32_t cy)
8765 {
8766 int32_t ffx = vbound(Map.CurrScr()->ffcs[i].x.getFloor(),0,240);
8767 int32_t ffy = vbound(Map.CurrScr()->ffcs[i].y.getFloor(),0,160);
8768 int32_t offx = ffx, offy = ffy;
8769 showxypos_ffc = i;
8770 doxypos((byte&)ffx,(byte&)ffy,15,SNAP_HALF,SNAP_NONE,true,cx-ffx,cy-ffy,(Map.CurrScr()->ffTileWidth(i)*16),(Map.CurrScr()->ffTileHeight(i)*16));
8771 if(ffx > 240) ffx = 240;
8772 if(ffy > 160) ffy = 160;
8773 if((ffx != offx) || (ffy != offy))
8774 {
8775 auto set_ffc_data = set_ffc_command::create_data(Map.CurrScr()->ffcs[i]);
8776 set_ffc_data.x = ffx;
8777 set_ffc_data.y = ffy;
8778 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
8779 saved = false;
8780 }
8781 }
8782
8783 void set_brush_width(int32_t width);
8784 void set_brush_height(int32_t height);
8785
8786 int32_t set_brush_width_1()
8787 {
8788 set_brush_width(1);
8789 return D_O_K;
8790 }
8791 int32_t set_brush_width_2()
8792 {
8793 set_brush_width(2);
8794 return D_O_K;
8795 }
8796 int32_t set_brush_width_3()
8797 {
8798 set_brush_width(3);
8799 return D_O_K;
8800 }
8801 int32_t set_brush_width_4()
8802 {
8803 set_brush_width(4);
8804 return D_O_K;
8805 }
8806 int32_t set_brush_width_5()
8807 {
8808 set_brush_width(5);
8809 return D_O_K;
8810 }
8811 int32_t set_brush_width_6()
8812 {
8813 set_brush_width(6);
8814 return D_O_K;
8815 }
8816 int32_t set_brush_width_7()
8817 {
8818 set_brush_width(7);
8819 return D_O_K;
8820 }
8821 int32_t set_brush_width_8()
8822 {
8823 set_brush_width(8);
8824 return D_O_K;
8825 }
8826 int32_t set_brush_width_9()
8827 {
8828 set_brush_width(9);
8829 return D_O_K;
8830 }
8831 int32_t set_brush_width_10()
8832 {
8833 set_brush_width(10);
8834 return D_O_K;
8835 }
8836 int32_t set_brush_width_11()
8837 {
8838 set_brush_width(11);
8839 return D_O_K;
8840 }
8841 int32_t set_brush_width_12()
8842 {
8843 set_brush_width(12);
8844 return D_O_K;
8845 }
8846 int32_t set_brush_width_13()
8847 {
8848 set_brush_width(13);
8849 return D_O_K;
8850 }
8851 int32_t set_brush_width_14()
8852 {
8853 set_brush_width(14);
8854 return D_O_K;
8855 }
8856 int32_t set_brush_width_15()
8857 {
8858 set_brush_width(15);
8859 return D_O_K;
8860 }
8861 int32_t set_brush_width_16()
8862 {
8863 set_brush_width(16);
8864 return D_O_K;
8865 }
8866
8867 int32_t set_brush_height_1()
8868 {
8869 set_brush_height(1);
8870 return D_O_K;
8871 }
8872 int32_t set_brush_height_2()
8873 {
8874 set_brush_height(2);
8875 return D_O_K;
8876 }
8877 int32_t set_brush_height_3()
8878 {
8879 set_brush_height(3);
8880 return D_O_K;
8881 }
8882 int32_t set_brush_height_4()
8883 {
8884 set_brush_height(4);
8885 return D_O_K;
8886 }
8887 int32_t set_brush_height_5()
8888 {
8889 set_brush_height(5);
8890 return D_O_K;
8891 }
8892 int32_t set_brush_height_6()
8893 {
8894 set_brush_height(6);
8895 return D_O_K;
8896 }
8897 int32_t set_brush_height_7()
8898 {
8899 set_brush_height(7);
8900 return D_O_K;
8901 }
8902 int32_t set_brush_height_8()
8903 {
8904 set_brush_height(8);
8905 return D_O_K;
8906 }
8907 int32_t set_brush_height_9()
8908 {
8909 set_brush_height(9);
8910 return D_O_K;
8911 }
8912 int32_t set_brush_height_10()
8913 {
8914 set_brush_height(10);
8915 return D_O_K;
8916 }
8917 int32_t set_brush_height_11()
8918 {
8919 set_brush_height(11);
8920 return D_O_K;
8921 }
8922
8923
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu brush_width_menu
8924 153 {
8925
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "1", set_brush_width_1 },
8926
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2", set_brush_width_2 },
8927
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "3", set_brush_width_3 },
8928
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "4", set_brush_width_4 },
8929
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "5", set_brush_width_5 },
8930
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "6", set_brush_width_6 },
8931
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "7", set_brush_width_7 },
8932
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "8", set_brush_width_8 },
8933
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "9", set_brush_width_9 },
8934
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "10", set_brush_width_10 },
8935
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "11", set_brush_width_11 },
8936
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "12", set_brush_width_12 },
8937
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "13", set_brush_width_13 },
8938
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "14", set_brush_width_14 },
8939
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "15", set_brush_width_15 },
8940
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "16", set_brush_width_16 },
8941 };
8942
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu brush_height_menu
8943 108 {
8944
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "1", set_brush_height_1 },
8945
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2", set_brush_height_2 },
8946
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "3", set_brush_height_3 },
8947
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "4", set_brush_height_4 },
8948
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "5", set_brush_height_5 },
8949
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "6", set_brush_height_6 },
8950
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "7", set_brush_height_7 },
8951
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "8", set_brush_height_8 },
8952
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "9", set_brush_height_9 },
8953
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "10", set_brush_height_10 },
8954
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "11", set_brush_height_11 },
8955 };
8956
8957 int toggle_autobrush();
8958 int toggle_combobrush();
8959 int toggle_floatbrush();
8960 enum
8961 {
8962 MENUID_BRUSH_AUTOBRUSH,
8963 MENUID_BRUSH_WIDTH,
8964 MENUID_BRUSH_HEIGHT,
8965 MENUID_BRUSH_COMBOBRUSH,
8966 MENUID_BRUSH_FLOATBRUSH,
8967 };
8968
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu brush_menu
8969 54 {
8970
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "AutoBrush", toggle_autobrush, MENUID_BRUSH_AUTOBRUSH },
8971
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Brush Width ", &brush_width_menu, MENUID_BRUSH_WIDTH },
8972
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Brush Height ", &brush_height_menu, MENUID_BRUSH_HEIGHT },
8973
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "ComboBrush", toggle_combobrush, MENUID_BRUSH_COMBOBRUSH },
8974
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "FloatBrush", toggle_floatbrush, MENUID_BRUSH_FLOATBRUSH },
8975 };
8976 int toggle_autobrush()
8977 {
8978 AutoBrush = AutoBrush ? 0 : 1;
8979 BrushWidth = BrushHeight = 1;
8980 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
8981 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
8982 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
8983 zc_set_config("zquest","autobrush",AutoBrush);
8984 return D_O_K;
8985 }
8986 int toggle_combobrush()
8987 {
8988 ComboBrush = ComboBrush ? 0 : 1;
8989 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
8990 zc_set_config("zquest","combo_brush",ComboBrush);
8991 return D_O_K;
8992 }
8993 int toggle_floatbrush()
8994 {
8995 FloatBrush = FloatBrush ? 0 : 1;
8996 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
8997 zc_set_config("zquest","float_brush",FloatBrush);
8998 return D_O_K;
8999 }
9000
9001 int32_t set_flood();
9002 int32_t set_fill_4();
9003 int32_t set_fill_8();
9004 int32_t set_fill2_4();
9005 int32_t set_fill2_8();
9006
9007 void flood()
9008 {
9009 int32_t drawmap, drawscr;
9010
9011 if(CurrentLayer==0)
9012 {
9013 drawmap=Map.getCurrMap();
9014 drawscr=Map.getCurrScr();
9015 }
9016 else
9017 {
9018 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9019 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9020 }
9021 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9022 if(!draw_mapscr) return;
9023
9024 saved=false;
9025
9026 if(!(draw_mapscr->valid&mVALID))
9027 {
9028 Map.CurrScr()->valid|=mVALID;
9029 draw_mapscr->valid|=mVALID;
9030 Map.setcolor(Color);
9031 }
9032
9033 bool include_combos = !(key[KEY_LSHIFT]||key[KEY_RSHIFT]);
9034 Map.StartListCommand();
9035
9036 for(int32_t i=0; i<176; i++)
9037 {
9038 if (draw_mode == dm_auto)
9039 draw_autocombo(i, gui_mouse_b() & 2);
9040 else
9041 Map.DoSetComboCommand(drawmap, drawscr, i, include_combos ? Combo : -1, CSet);
9042 }
9043
9044 Map.FinishListCommand();
9045 refresh(rMAP+rSCRMAP);
9046 }
9047 void flood_flag()
9048 {
9049 int32_t drawmap, drawscr;
9050
9051 if(CurrentLayer==0)
9052 {
9053 drawmap=Map.getCurrMap();
9054 drawscr=Map.getCurrScr();
9055 }
9056 else
9057 {
9058 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9059 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9060 }
9061 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9062 if(!draw_mapscr) return;
9063
9064 saved=false;
9065
9066 if(!(draw_mapscr->valid&mVALID))
9067 {
9068 Map.CurrScr()->valid|=mVALID;
9069 draw_mapscr->valid|=mVALID;
9070 Map.setcolor(Color);
9071 }
9072
9073 Map.StartListCommand();
9074 for(int32_t i=0; i<176; i++)
9075 {
9076 Map.DoSetFlagCommand(drawmap, drawscr, i, Flag);
9077 }
9078 Map.FinishListCommand();
9079
9080 refresh(rMAP+rSCRMAP);
9081 }
9082
9083 void fill_4()
9084 {
9085 int32_t drawmap, drawscr;
9086
9087 if(CurrentLayer==0)
9088 {
9089 drawmap=Map.getCurrMap();
9090 drawscr=Map.getCurrScr();
9091 }
9092 else
9093 {
9094 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9095 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9096 }
9097 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9098 if(!draw_mapscr) return;
9099
9100 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9101 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9102 int32_t by= (y>>4)/(mapscreensize);
9103 int32_t bx= (x>>4)/(mapscreensize);
9104
9105 if(draw_mode == dm_cpool || draw_mode == dm_auto
9106 || (draw_mapscr->cset[(by<<4)+bx]!=CSet ||
9107 (draw_mapscr->data[(by<<4)+bx]!=Combo &&
9108 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9109 {
9110 saved=false;
9111
9112 if(!(draw_mapscr->valid&mVALID))
9113 {
9114 Map.CurrScr()->valid|=mVALID;
9115 draw_mapscr->valid|=mVALID;
9116 Map.setcolor(Color);
9117 }
9118
9119 Map.StartListCommand();
9120 if (draw_mode == dm_auto && (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE ||
9121 combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4))
9122 {
9123 draw_autocombo_command((by << 4) + bx);
9124 }
9125 else
9126 {
9127 bool filled_combos[176] = { false };
9128 fill(drawmap, drawscr, draw_mapscr,
9129 (draw_mapscr->data[(by << 4) + bx]),
9130 (draw_mapscr->cset[(by << 4) + bx]), bx, by, 255, 0, (key[KEY_LSHIFT] || key[KEY_RSHIFT]), filled_combos);
9131 }
9132 Map.FinishListCommand();
9133 refresh(rMAP+rSCRMAP);
9134 }
9135 }
9136 void fill_4_flag()
9137 {
9138 int32_t drawmap, drawscr;
9139
9140 if(CurrentLayer==0)
9141 {
9142 drawmap=Map.getCurrMap();
9143 drawscr=Map.getCurrScr();
9144 }
9145 else
9146 {
9147 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9148 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9149 }
9150 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9151 if(!draw_mapscr) return;
9152
9153 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9154 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9155 int32_t by= (y>>4)/(mapscreensize);
9156 int32_t bx= (x>>4)/(mapscreensize);
9157
9158 if(draw_mapscr->sflag[(by<<4)+bx] != Flag)
9159 {
9160 saved=false;
9161
9162 if(!(draw_mapscr->valid&mVALID))
9163 {
9164 Map.CurrScr()->valid|=mVALID;
9165 draw_mapscr->valid|=mVALID;
9166 Map.setcolor(Color);
9167 }
9168
9169 Map.StartListCommand();
9170 fill_flag(drawmap, drawscr, draw_mapscr,
9171 (draw_mapscr->sflag[(by<<4)+bx]),
9172 bx, by, 255, 0);
9173 Map.FinishListCommand();
9174 refresh(rMAP+rSCRMAP);
9175 }
9176 }
9177 void fill_8()
9178 {
9179 int32_t drawmap, drawscr;
9180
9181 if(CurrentLayer==0)
9182 {
9183 drawmap=Map.getCurrMap();
9184 drawscr=Map.getCurrScr();
9185 }
9186 else
9187 {
9188 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9189 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9190 }
9191 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9192 if(!draw_mapscr) return;
9193
9194 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9195 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9196 int32_t by= (y>>4)/(mapscreensize);
9197 int32_t bx= (x>>4)/(mapscreensize);
9198
9199 if(draw_mode == dm_cpool || draw_mode == dm_auto
9200 || (draw_mapscr->cset[(by<<4)+bx]!=CSet ||
9201 (draw_mapscr->data[(by<<4)+bx]!=Combo &&
9202 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9203 {
9204 saved=false;
9205
9206 if(!(draw_mapscr->valid&mVALID))
9207 {
9208 Map.CurrScr()->valid|=mVALID;
9209 draw_mapscr->valid|=mVALID;
9210 Map.setcolor(Color);
9211 }
9212
9213 Map.StartListCommand();
9214 bool filled_combos[176] = { false };
9215 fill(drawmap, drawscr, draw_mapscr,
9216 (draw_mapscr->data[(by<<4)+bx]),
9217 (draw_mapscr->cset[(by<<4)+bx]), bx, by, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]), filled_combos);
9218 Map.FinishListCommand();
9219 refresh(rMAP+rSCRMAP);
9220 }
9221 }
9222 void fill_8_flag()
9223 {
9224 int32_t drawmap, drawscr;
9225
9226 if(CurrentLayer==0)
9227 {
9228 drawmap=Map.getCurrMap();
9229 drawscr=Map.getCurrScr();
9230 }
9231 else
9232 {
9233 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9234 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9235 }
9236 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9237 if(!draw_mapscr) return;
9238
9239 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9240 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);
9241 int32_t by= (y>>4)/(mapscreensize);
9242 int32_t bx= (x>>4)/(mapscreensize);
9243
9244 if(draw_mapscr->sflag[(by<<4)+bx]!=Flag)
9245 {
9246 saved=false;
9247
9248 if(!(draw_mapscr->valid&mVALID))
9249 {
9250 Map.CurrScr()->valid|=mVALID;
9251 draw_mapscr->valid|=mVALID;
9252 Map.setcolor(Color);
9253 }
9254
9255 Map.StartListCommand();
9256 fill_flag(drawmap, drawscr, draw_mapscr,
9257 (draw_mapscr->sflag[(by<<4)+bx]),
9258 bx, by, 255, 1);
9259 Map.FinishListCommand();
9260 refresh(rMAP+rSCRMAP);
9261 }
9262 }
9263
9264 void fill2_4()
9265 {
9266 int32_t drawmap, drawscr;
9267
9268 if(CurrentLayer==0)
9269 {
9270 drawmap=Map.getCurrMap();
9271 drawscr=Map.getCurrScr();
9272 }
9273 else
9274 {
9275 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9276 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9277 }
9278 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9279 if(!draw_mapscr) return;
9280
9281 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9282 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);;
9283 int32_t by= (((y&0xF0))>>4)/(mapscreensize);
9284 int32_t bx= (x>>4)/(mapscreensize);
9285
9286 saved=false;
9287
9288 if(!(draw_mapscr->valid&mVALID))
9289 {
9290 Map.CurrScr()->valid|=mVALID;
9291 draw_mapscr->valid|=mVALID;
9292 Map.setcolor(Color);
9293 }
9294
9295 Map.StartListCommand();
9296 fill2(draw_mapscr, Combo, CSet, bx, by, 255, 0, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9297 Map.FinishListCommand();
9298 refresh(rMAP+rSCRMAP);
9299 }
9300
9301 void fill2_8()
9302 {
9303 int32_t drawmap, drawscr;
9304
9305 if(CurrentLayer==0)
9306 {
9307 drawmap=Map.getCurrMap();
9308 drawscr=Map.getCurrScr();
9309 }
9310 else
9311 {
9312 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9313 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9314 }
9315 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9316 if(!draw_mapscr) return;
9317
9318 int32_t x=gui_mouse_x()-mapscreen_x-(showedges?(16*mapscreensize):0);
9319 int32_t y=gui_mouse_y()-mapscreen_y-(showedges?(16*mapscreensize):0);;
9320 int32_t by= (((y&0xF0))>>4)/(mapscreensize);
9321 int32_t bx= (x>>4)/(mapscreensize);
9322
9323 saved=false;
9324
9325 if(!(draw_mapscr->valid&mVALID))
9326 {
9327 Map.CurrScr()->valid|=mVALID;
9328 draw_mapscr->valid|=mVALID;
9329 Map.setcolor(Color);
9330 }
9331
9332 Map.StartListCommand();
9333 fill2(draw_mapscr, Combo, CSet, bx, by, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9334 Map.FinishListCommand();
9335 refresh(rMAP+rSCRMAP);
9336 }
9337
9338 enum
9339 {
9340
9341 };
9342
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu fill_menu
9343 54 {
9344
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Flood", set_flood, 0 },
9345
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Fill (4-way)", set_fill_4, 1 },
9346
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Fill (8-way)", set_fill_8, 2 },
9347
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Fill2 (4-way)", set_fill2_4, 3 },
9348
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Fill2 (8-way)", set_fill2_8, 4 },
9349 };
9350 void set_filltype(int ty)
9351 {
9352 fill_type = ty;
9353 fill_menu.select_only_uid(ty);
9354 }
9355
9356 int32_t set_flood()
9357 {
9358 set_filltype(0);
9359 return D_O_K;
9360 }
9361
9362 int32_t set_fill_4()
9363 {
9364 set_filltype(1);
9365 return D_O_K;
9366 }
9367
9368 int32_t set_fill_8()
9369 {
9370 set_filltype(2);
9371 return D_O_K;
9372 }
9373
9374 int32_t set_fill2_4()
9375 {
9376 set_filltype(3);
9377 return D_O_K;
9378 }
9379
9380 int32_t set_fill2_8()
9381 {
9382 set_filltype(4);
9383 return D_O_K;
9384 }
9385
9386 int32_t draw_block_1_2()
9387 {
9388 draw_block(mousecomboposition,1,2);
9389 return D_O_K;
9390 }
9391
9392 int32_t draw_block_2_1()
9393 {
9394 draw_block(mousecomboposition,2,1);
9395 return D_O_K;
9396 }
9397
9398 int32_t draw_block_2_2()
9399 {
9400 draw_block(mousecomboposition,2,2);
9401 return D_O_K;
9402 }
9403
9404 int32_t draw_block_2_3()
9405 {
9406 draw_block(mousecomboposition,2,3);
9407 return D_O_K;
9408 }
9409
9410 int32_t draw_block_3_2()
9411 {
9412 draw_block(mousecomboposition,3,2);
9413 return D_O_K;
9414 }
9415
9416 int32_t draw_block_3_3()
9417 {
9418 draw_block(mousecomboposition,3,3);
9419 return D_O_K;
9420 }
9421
9422 int32_t draw_block_4_2()
9423 {
9424 draw_block(mousecomboposition,4,2);
9425 return D_O_K;
9426 }
9427
9428 int32_t draw_block_4_4()
9429 {
9430 draw_block(mousecomboposition,4,4);
9431 return D_O_K;
9432 }
9433
9434
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu draw_block_menu
9435 81 {
9436
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "1x2", draw_block_1_2 },
9437
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2x1", draw_block_2_1 },
9438
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2x2", draw_block_2_2 },
9439
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "2x3", draw_block_2_3 },
9440
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "3x2", draw_block_3_2 },
9441
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "3x3", draw_block_3_3 },
9442
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "4x2", draw_block_4_2 },
9443
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "4x4", draw_block_4_4 },
9444 };
9445
9446
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu paste_screen_menu
9447 45 {
9448
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste", onPaste },
9449
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste All", onPasteAll },
9450
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste to All", onPasteToAll },
9451
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste All to All", onPasteAllToAll },
9452 };
9453
9454 int32_t scrollto_cmb(int32_t cid)
9455 {
9456 auto& sqr = combolist[current_combolist];
9457 int32_t res = vbound(cid-(sqr.w*sqr.h/2),0,MAXCOMBOS-(sqr.w*sqr.h));
9458 res -= res%sqr.w;
9459 return res;
9460 }
9461 int32_t scrollto_alias(int32_t alid)
9462 {
9463 auto& sqr = comboaliaslist[current_comboalist];
9464 int32_t res = vbound(alid-(sqr.w*sqr.h/2),0,MAXCOMBOALIASES-(sqr.w*sqr.h));
9465 res -= res%sqr.w;
9466 return res;
9467 }
9468
9469 int32_t scrollto_cpool(int32_t cpid)
9470 {
9471 auto& sqr = comboaliaslist[current_cpoollist];
9472 int32_t res = vbound(cpid-(sqr.w*sqr.h/2),0,MAXCOMBOPOOLS-(sqr.w*sqr.h));
9473 res -= res%sqr.w;
9474 return res;
9475 }
9476
9477 int32_t scrollto_cauto(int32_t caid)
9478 {
9479 auto& sqr = comboaliaslist[current_cautolist];
9480 int32_t res = vbound(caid - (sqr.w * sqr.h / 2), 0, MAXCOMBOPOOLS - (sqr.w * sqr.h));
9481 res -= res % sqr.w;
9482 return res;
9483 }
9484
9485 void add_favorite_combo_block(int32_t favind, int32_t cid, bool force)
9486 {
9487 int32_t w = vbound(BrushWidth, 1, 4);
9488 int32_t h = vbound(BrushHeight, 1, 7);
9489 for (int32_t xi = 0; xi < w; ++xi)
9490 {
9491 for (int32_t yi = 0; yi < h; ++yi)
9492 {
9493 int32_t cx = cid % 4;
9494 int32_t cy = cid / 4;
9495 int32_t cc = (cy + yi) * 4 + cx + xi;
9496 int32_t fx = favind % FAVORITECOMBO_PER_ROW;
9497 int32_t fy = favind / FAVORITECOMBO_PER_ROW;
9498 int32_t fc = (fy + yi) * FAVORITECOMBO_PER_ROW + fx + xi + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
9499
9500 if (cx + xi < 4 && cc < MAXCOMBOS && fx + xi < FAVORITECOMBO_PER_ROW && fy + yi < FAVORITECOMBO_PER_COLUMN)
9501 {
9502 if (favorite_combos[fc] < 0 || force)
9503 {
9504 favorite_combo_modes[fc] = dm_normal;
9505 favorite_combos[fc] = cc;
9506 }
9507 }
9508 }
9509 }
9510 }
9511
9512 void onRCSelectCombo(int32_t c)
9513 {
9514 int32_t drawmap, drawscr;
9515
9516 if(CurrentLayer==0)
9517 {
9518 drawmap=Map.getCurrMap();
9519 drawscr=Map.getCurrScr();
9520 }
9521 else
9522 {
9523 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9524 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9525 }
9526 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9527 if(!draw_mapscr) return;
9528
9529 Combo=draw_mapscr->data[c];
9530 if(AutoBrush)
9531 BrushWidth = BrushHeight = 1;
9532 }
9533
9534 void onRCScrollToombo(int32_t c)
9535 {
9536 int32_t drawmap, drawscr;
9537
9538 if(CurrentLayer==0)
9539 {
9540 drawmap=Map.getCurrMap();
9541 drawscr=Map.getCurrScr();
9542 }
9543 else
9544 {
9545 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9546 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9547 }
9548 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9549 if(!draw_mapscr) return;
9550
9551 auto& sqr = combolist[current_combolist];
9552 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
9553 }
9554
9555 enum
9556 {
9557 MENUID_RCSCREEN_PASTE,
9558 MENUID_RCSCREEN_ADVPASTE,
9559 MENUID_RCSCREEN_SPECPASTE,
9560 };
9561
1/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 static NewMenu rc_menu_screen
9562 45 {
9563
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Copy Screen", onCopy },
9564
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "Paste Screen", &paste_screen_menu, MENUID_RCSCREEN_PASTE },
9565
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "...Advanced Paste", &paste_menu, MENUID_RCSCREEN_ADVPASTE },
9566
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 { "...Special Paste", &paste_item_menu, MENUID_RCSCREEN_SPECPASTE },
9567 };
9568
9569 void follow_twarp(int warpindex)
9570 {
9571 if(warpindex >= 4)
9572 {
9573 InfoDialog("Random Tile Warp",
9574 "This is a random tile warp combo, so it chooses"
9575 " randomly between the screen's four Tile Warps.").show();
9576 warpindex=zc_oldrand()&3;
9577 }
9578
9579 int32_t tm = Map.getCurrMap();
9580 int32_t ts = Map.getCurrScr();
9581 int32_t wt = Map.CurrScr()->tilewarptype[warpindex];
9582
9583 if(wt==wtCAVE || wt==wtNOWARP)
9584 {
9585 char buf[56];
9586 InfoDialog(warptype_string[wt],fmt::format("This screen's Tile Warp {} is set to {}, so it doesn't lead to another screen.",'A'+warpindex,warptype_string[wt]));
9587 return;
9588 }
9589
9590 Map.dowarp(0,warpindex);
9591
9592 if(ts!=Map.getCurrScr() || tm!=Map.getCurrMap())
9593 {
9594 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(warpindex*2))&3;
9595 FlashWarpClk = 32;
9596 }
9597 }
9598 void edit_twarp(int warpindex)
9599 {
9600 if(warpindex>=4)
9601 {
9602 InfoDialog("Random Tile Warp",
9603 "This is a random tile warp combo, so it chooses"
9604 " randomly between the screen's four Tile Warps.").show();
9605 warpindex=zc_oldrand()&3;
9606 }
9607
9608 if(warpindex > -1 && warpindex < 4)
9609 onTileWarpIndex(warpindex);
9610 }
9611
9612 int toggle_linked_scrolling()
9613 {
9614 LinkedScroll = LinkedScroll ? 0 : 1;
9615 zc_set_config("zquest","linked_comboscroll",LinkedScroll);
9616 return D_O_K;
9617 }
9618 void on_scroll_cpane()
9619 {
9620 switch (draw_mode)
9621 {
9622 case dm_alias:
9623 combo_alistpos[current_comboalist] = scrollto_alias(combo_apos);
9624 break;
9625 case dm_cpool:
9626 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
9627 break;
9628 case dm_auto:
9629 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
9630 break;
9631 default:
9632 First[current_combolist] = scrollto_cmb(Combo);
9633 break;
9634 }
9635 }
9636 void on_edit_cpane()
9637 {
9638 switch (draw_mode)
9639 {
9640 case dm_alias:
9641 onEditComboAlias();
9642 break;
9643 case dm_cpool:
9644 onEditComboPool();
9645 break;
9646 case dm_auto:
9647 onEditAutoCombo();
9648 break;
9649 default:
9650 reset_combo_animations();
9651 reset_combo_animations2();
9652 edit_combo(Combo, true, CSet);
9653 setup_combo_animations();
9654 setup_combo_animations2();
9655 break;
9656 }
9657 }
9658 void on_cpane_page()
9659 {
9660 switch(draw_mode)
9661 {
9662 case dm_normal:
9663 combo_screen(Combo>>8,Combo);
9664 break;
9665 case dm_alias:
9666 call_alias_pages(combo_apos);
9667 break;
9668 case dm_auto:
9669 call_autoc_pages(combo_auto_pos);
9670 break;
9671 case dm_cpool:
9672 call_cpool_pages(combo_pool_pos);
9673 break;
9674 }
9675 }
9676 void open_cpane_tilepage()
9677 {
9678 onGotoTiles(combobuf[Combo].o_tile);
9679 }
9680 static int _clicked_fav = 0;
9681 void fav_rc_remove()
9682 {
9683 favorite_combo_modes[_clicked_fav] = dm_normal;
9684 favorite_combos[_clicked_fav] = -1;
9685 saved = false;
9686 }
9687 void popup_favorites_rc(int f, int x, int y)
9688 {
9689 _clicked_fav = f;
9690 string type;
9691 switch (draw_mode)
9692 {
9693 case dm_alias:
9694 type = "Alias";
9695 break;
9696 case dm_cpool:
9697 type = "Pool";
9698 break;
9699 case dm_auto:
9700 type = "Autocombo";
9701 break;
9702 case dm_normal:
9703 type = "Combo";
9704 break;
9705 default: return;
9706 }
9707 NewMenu rcmenu
9708 {
9709 { fmt::format("Scroll to {}", type), on_scroll_cpane },
9710 { fmt::format("Edit {}", type), on_edit_cpane },
9711 { fmt::format("Open {} Page", type), on_cpane_page },
9712 { fmt::format("Remove Fav {}", type), fav_rc_remove },
9713 };
9714 switch (draw_mode)
9715 {
9716 case dm_normal:
9717 rcmenu.add({
9718 {},
9719 { "Open Tile Page", open_cpane_tilepage },
9720 });
9721 break;
9722 }
9723 rcmenu.pop(x, y);
9724 }
9725 void popup_cpane_rc(int x, int y)
9726 {
9727 string type;
9728 switch (draw_mode)
9729 {
9730 case dm_alias:
9731 type = "Alias";
9732 break;
9733 case dm_cpool:
9734 type = "Pool";
9735 break;
9736 case dm_auto:
9737 type = "Autocombo";
9738 break;
9739 case dm_normal:
9740 type = "Combo";
9741 break;
9742 default: return;
9743 }
9744 NewMenu rcmenu;
9745 switch(draw_mode)
9746 {
9747 case dm_normal:
9748 rcmenu.add({
9749 { fmt::format("Edit {}", type), on_edit_cpane },
9750 { fmt::format("Open {} Page", type), on_cpane_page },
9751 { "Open Tile Page", open_cpane_tilepage },
9752 { "Combo Locations", onComboLocationReport },
9753 {},
9754 { "Scroll to Page...", onGotoPage },
9755 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9756 });
9757 break;
9758 case dm_alias:
9759 case dm_cpool:
9760 case dm_auto:
9761 rcmenu.add({
9762 { fmt::format("Edit {}", type), on_edit_cpane },
9763 { fmt::format("Open {} Page", type), on_cpane_page },
9764 {},
9765 { "Scroll to Page...", onGotoPage },
9766 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9767 });
9768 break;
9769 }
9770 rcmenu.pop(x, y);
9771 }
9772
9773 void set_brush_width(int32_t width)
9774 {
9775 BrushWidth = width;
9776 for(int q = 0; q < brush_width_menu.size(); ++q)
9777 brush_width_menu.at(q)->select(q==BrushWidth-1);
9778 refresh(rALL);
9779 }
9780
9781 void set_brush_height(int32_t height)
9782 {
9783 BrushHeight = height;
9784 for(int q = 0; q < brush_height_menu.size(); ++q)
9785 brush_height_menu.at(q)->select(q==BrushHeight-1);
9786 refresh(rALL);
9787 }
9788
9789 void restore_mouse()
9790 {
9791 ComboBrushPause=1;
9792 MouseSprite::set(ZQM_NORMAL);
9793 }
9794
9795 static int32_t comboa_cnt=0;
9796 static int32_t combop_cnt=0;
9797 static int32_t layer_cnt=0;
9798
9799 static char paste_ffc_menu_text[21];
9800 static char paste_ffc_menu_text2[21];
9801 static char follow_warp_menu_text[21];
9802 static char follow_warp_menu_text2[21];
9803
9804 static int fake_mouse_b(){return 0;}
9805 static int (*mouseb_proc)();
9806 static bool killed_mouse = false;
9807 void zq_killmouse()
9808 {
9809 if(killed_mouse) return;
9810 mouseb_proc = gui_mouse_b;
9811 gui_mouse_b = fake_mouse_b;
9812 killed_mouse = true;
9813 }
9814 void zq_restoremouse()
9815 {
9816 if(!killed_mouse) return;
9817 gui_mouse_b = mouseb_proc;
9818 killed_mouse = false;
9819 }
9820
9821
9822 void domouse()
9823 {
9824 static int mouse_down = 0;
9825 static int32_t scrolldelay = 0;
9826 auto mousexy = zc_get_mouse();
9827 auto x = mousexy.first;
9828 auto y = mousexy.second;
9829 double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
9830 double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
9831 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
9832 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreensize):0);
9833 int32_t cx=(x-startxint)/int32_t(16*mapscreensize);
9834 int32_t cy=(y-startyint)/int32_t(16*mapscreensize);
9835 int32_t c=(cy*16)+cx;
9836
9837 if (draw_mode == dm_auto)
9838 {
9839 if (c != mousecomboposition)
9840 combobrushoverride = get_autocombo_floating_cid(c, false);
9841 }
9842 else
9843 combobrushoverride = -1;
9844
9845 mousecomboposition=c;
9846 update_combobrush();
9847 // put_combo(brushbmp,0,0,Combo,CSet,0,0);
9848
9849 ++scrolldelay;
9850
9851 bool x_on_list = false;
9852 for(auto q = 0; q < num_combo_cols; ++q)
9853 {
9854 if((x>=combolist[q].x) && (x<combolist[q].x+(combolist[q].xscale*combolist[q].w)))
9855 {
9856 x_on_list = true;
9857 break;
9858 }
9859 }
9860 if(MouseScroll && x_on_list && (key[KEY_LSHIFT] || key[KEY_RSHIFT] || (scrolldelay&3)==0))
9861 {
9862 int32_t test_list=0;
9863
9864 for(test_list=0; test_list<3; ++test_list)
9865 {
9866 if((x>=combolist[test_list].x) && (x<combolist[test_list].x+(combolist[test_list].xscale*combolist[test_list].w)))
9867 {
9868 break;
9869 }
9870 }
9871
9872 if(test_list<3)
9873 {
9874 if(y>=combolist[test_list].y-mouse_scroll_h && y<=combolist[test_list].y && First[test_list])
9875 {
9876 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9877 {
9878 First[test_list]=0;
9879 }
9880 else if(CHECK_CTRL_CMD)
9881 {
9882 First[test_list]-=zc_min(First[test_list],256);
9883 }
9884 else if(key[KEY_ALT] || key[KEY_ALTGR])
9885 {
9886 First[test_list]-=zc_min(First[test_list],(combolist[test_list].w*combolist[test_list].h));
9887 }
9888 else
9889 {
9890 First[test_list]-=zc_min(First[test_list],combolist[test_list].w);
9891 }
9892 }
9893
9894 if(y>=combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)-1 && y<combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)+mouse_scroll_h-1 && First[test_list]<(MAXCOMBOS-(combolist[test_list].w*combolist[test_list].h)))
9895 {
9896 int32_t offset = combolist[test_list].w*combolist[test_list].h;
9897
9898 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9899 {
9900 First[test_list]=MAXCOMBOS-offset;
9901 }
9902 else if(CHECK_CTRL_CMD)
9903 {
9904 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+256);
9905 }
9906 else if(key[KEY_ALT] || key[KEY_ALTGR])
9907 {
9908 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+ offset);
9909 }
9910 else
9911 {
9912 First[test_list] = zc_min(MAXCOMBOS - offset, First[test_list] + combolist[test_list].w);
9913 }
9914 }
9915 }
9916 }
9917
9918 //-------------
9919 //tooltip stuff
9920 //-------------
9921 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreensize)-1,startyint+(176*mapscreensize)-1))
9922 {
9923 static int mapscr_tooltip_id = ttip_register_id();
9924 bool did_ffttip = false;
9925 for(int32_t i=MAXFFCS-1; i>=0; i--)
9926 if(Map.CurrScr()->ffcs[i].data !=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffc_overlay)))
9927 {
9928 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
9929 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
9930 int32_t ffw = Map.CurrScr()->ffTileWidth(i)*16;
9931 int32_t ffh = Map.CurrScr()->ffTileHeight(i)*16;
9932 int32_t cx2 = (x-startxint)/mapscreensize;
9933 int32_t cy2 = (y-startyint)/mapscreensize;
9934
9935 if(cx2 >= ffx && cx2 < ffx+ffw && cy2 >= ffy && cy2 < ffy+ffh)
9936 {
9937 // FFC tooltip
9938 if(tooltip_current_ffc != i)
9939 {
9940 clear_tooltip();
9941 }
9942
9943 tooltip_current_ffc = i;
9944 char msg[1024] = {0};
9945 auto& ff = Map.CurrScr()->ffcs[i];
9946 sprintf(msg,"FFC: %d Combo: %d\nCSet: %d Type: %s\nScript: %s",
9947 i+1, ff.data,ff.data,
9948 combo_class_buf[combobuf[ff.data].type].name,
9949 (ff.script<=0 ? "(None)" : ffcmap[ff.script-1].scriptname.substr(0,400).c_str()));
9950 ttip_install(mapscr_tooltip_id, msg, startxint+(ffx*mapscreensize), startyint+(ffy*mapscreensize), ffw*mapscreensize, ffh*mapscreensize, x, y);
9951 did_ffttip = true;
9952 break;
9953 }
9954 }
9955 if(!did_ffttip)
9956 {
9957 int32_t drawmap;
9958 int32_t drawscr;
9959
9960 if(CurrentLayer==0)
9961 {
9962 drawmap=Map.getCurrMap();
9963 drawscr=Map.getCurrScr();
9964 }
9965 else
9966 {
9967 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9968 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9969 }
9970
9971 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9972 if(unsigned(c) < 176 && draw_mapscr && !gui_mouse_b())
9973 {
9974 int cid = draw_mapscr->data[c];
9975 newcombo const& cmb = combobuf[cid];
9976 std::ostringstream oss;
9977 int cs = draw_mapscr->cset[c];
9978 int sflag = draw_mapscr->sflag[c];
9979 oss << "Pos: " << c
9980 << "\nCombo: " << cid
9981 << "\nCSet: " << cs;
9982 if(sflag || cmb.flag)
9983 oss << "\nFlags: " << sflag << ", " << (int)cmb.flag;
9984 if(cmb.type)
9985 oss << "\nCombo type: " << combo_class_buf[cmb.type].name;
9986 if(cmb.label[0])
9987 oss << "\nLabel: " << cmb.label;
9988 ttip_install(mapscr_tooltip_id, oss.str().c_str(), startxint+(cx*16*mapscreensize), startyint+(cy*16*mapscreensize), 16*mapscreensize, 16*mapscreensize, x, y);
9989 }
9990 }
9991 }
9992
9993 {
9994 size_and_pos* squares[4] = {&itemsqr_pos,&stairsqr_pos,&warparrival_pos,&flagsqr_pos};
9995 for(int32_t j=0; j<4; j++)
9996 {
9997 auto& square = *squares[j];
9998 if(square.rect(x,y))
9999 {
10000 char msg[160];
10001 sprintf(msg,
10002 j==0 ? "Item Location" :
10003 j==1 ? "Stairs Secret\nTriggered when a Trigger Push Block is pushed." :
10004 j==2 ? "Arrival Square\nPlayer's location when they begin/resume the game." :
10005 "Combo Flags");
10006 update_tooltip(x,y,square,msg);
10007 }
10008 }
10009
10010 // Warp Returns
10011 for(int32_t j=0; j<4; j++)
10012 {
10013 size_and_pos& wret = warpret_pos[j];
10014 if(wret.rect(x,y))
10015 {
10016 char msg[160];
10017 sprintf(msg,"Warp Return Square %c\nPlayer's destination after warping to this screen.",(char)('A'+j));
10018 update_tooltip(x,y,wret,msg);
10019 }
10020 }
10021
10022 // Enemies
10023 if(enemy_prev_pos.rect(x,y))
10024 {
10025 char msg[160];
10026 sprintf(msg,"Enemies that appear on this screen.");
10027 update_tooltip(x,y,enemy_prev_pos,msg);
10028 }
10029
10030 int32_t cmd = commands_list.rectind(x,y);
10031 if(cmd > -1)
10032 {
10033 update_tooltip(x,y,commands_list.subsquare(cmd),
10034 fmt::format("Fav Command {}: {}\n{}", cmd,
10035 get_hotkey_name(favorite_commands[cmd]),
10036 get_hotkey_helptext(favorite_commands[cmd])).c_str());
10037 }
10038 }
10039
10040 if(draw_mode==dm_alias)
10041 {
10042 for(int32_t j=0; j<num_combo_cols; ++j)
10043 {
10044 auto& sqr = comboaliaslist[j];
10045 auto ind = sqr.rectind(x,y);
10046 if(ind > -1)
10047 {
10048 auto c2=ind+combo_alistpos[j];
10049 char msg[80];
10050 sprintf(msg, "Combo alias %d", c2);
10051 update_tooltip(x,y,sqr.subsquare(ind), msg);
10052 }
10053 }
10054 }
10055 else if(draw_mode==dm_cpool)
10056 {
10057 for(int32_t j=0; j<num_combo_cols; ++j)
10058 {
10059 auto& sqr = comboaliaslist[j];
10060 auto ind = sqr.rectind(x,y);
10061 if(ind > -1)
10062 {
10063 auto c2=ind+combo_pool_listpos[j];
10064 char msg[80];
10065 sprintf(msg, "Combo Pool %d", c2);
10066 update_tooltip(x,y,sqr.subsquare(ind), msg);
10067 }
10068 }
10069 if(cpool_prev_visible && combopool_prevbtn.rect(x,y))
10070 {
10071 if(do_layer_button_reset(combopool_prevbtn.x,combopool_prevbtn.y,
10072 combopool_prevbtn.w,combopool_prevbtn.h,
10073 weighted_cpool ? "Weighted" : "Unweighted",0,true))
10074 {
10075 weighted_cpool = !weighted_cpool;
10076 }
10077 }
10078 }
10079 else if (draw_mode == dm_auto)
10080 {
10081 for (int32_t j = 0; j < num_combo_cols; ++j)
10082 {
10083 auto& sqr = comboaliaslist[j];
10084 auto ind = sqr.rectind(x, y);
10085 if (ind > -1)
10086 {
10087 auto c2 = ind + combo_auto_listpos[j];
10088 char msg[80];
10089 sprintf(msg, "Auto Combo %d", c2);
10090 update_tooltip(x, y, sqr.subsquare(ind), msg);
10091 }
10092 }
10093 }
10094 else
10095 {
10096 if(combo_preview.rect(x,y))
10097 {
10098 auto str = "Combo Colors:\n"+get_combo_colornames(Combo,CSet);
10099 update_tooltip(x,y,combo_preview,str.c_str());
10100 }
10101 else if(comboprev_buf[0] && combo_preview_text1.rect(x,y))
10102 {
10103 update_tooltip(x,y,combo_preview_text1,comboprev_buf);
10104 }
10105 else if(comboprev_buf2[0] && combo_preview_text2.rect(x,y))
10106 {
10107 update_tooltip(x,y,combo_preview_text2,comboprev_buf2);
10108 }
10109 else for(int32_t j=0; j<num_combo_cols; ++j)
10110 {
10111 auto& sqr = combolist[j];
10112 auto ind = sqr.rectind(x,y);
10113 if(ind > -1)
10114 {
10115 int32_t c2=ind+First[j];
10116 std::ostringstream oss;
10117 newcombo const& cmb = combobuf[c2];
10118 oss << "Combo " << c2 << ": " << combo_class_buf[cmb.type].name;
10119 if(cmb.flag != 0)
10120 oss << "\nInherent flag: " << ZI.getMapFlagName(cmb.flag);
10121 if(!cmb.label.empty())
10122 oss << "\nLabel: " << cmb.label;
10123
10124 update_tooltip(x,y,sqr.subsquare(ind), oss.str().c_str());
10125 }
10126 }
10127 }
10128
10129 if (favorites_list.rect(x, y))
10130 {
10131 int32_t f = favorites_list.rectind(x, y);
10132 int32_t row = f / favorites_list.w;
10133 int32_t col = f % favorites_list.w;
10134 f = (row * FAVORITECOMBO_PER_ROW) + col;
10135
10136 auto& sqr = favorites_list.subsquare(col, row);
10137
10138 char buf[180];
10139 if (favorite_combos[f] == -1)
10140 sprintf(buf, "Fav Combo %d\nEmpty", f);
10141 else
10142 {
10143 switch (favorite_combo_modes[f])
10144 {
10145 case dm_alias:
10146 sprintf(buf, "Fav Combo %d\nAlias %d", f, favorite_combos[f]);
10147 break;
10148 case dm_cpool:
10149 sprintf(buf, "Fav Combo %d\nPool %d", f, favorite_combos[f]);
10150 break;
10151 case dm_auto:
10152 sprintf(buf, "Fav Combo %d\nAutocombo %d", f, favorite_combos[f]);
10153 break;
10154 default:
10155 sprintf(buf, "Fav Combo %d\nCombo %d", f, favorite_combos[f]);
10156 }
10157 }
10158 update_tooltip(x, y, sqr, buf);
10159 }
10160
10161 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
10162 auto ind = real_mini.rectind(x,y);
10163 if(ind > -1)
10164 {
10165 char buf[80];
10166 sprintf(buf,"0x%02X (%d)", ind, ind);
10167 ttip_install(minimap_tooltip_id, buf, real_mini.subsquare(ind), real_mini.x+real_mini.tw(), real_mini.y-16);
10168 ttip_set_highlight_thickness(minimap_tooltip_id, zoomed_minimap ? 2 : 1);
10169 // Make sure always above the other tooltip items to the right of the map (even in big map mode).
10170 ttip_set_z_index(minimap_tooltip_id, 100);
10171 ttip_clear_timer();
10172 }
10173 else
10174 {
10175 ttip_uninstall(minimap_tooltip_id);
10176 }
10177
10178 // Mouse clicking stuff
10179 int real_mb = gui_mouse_b();
10180 int mb = real_mb & ~mouse_down; //Only handle clicks that have not been handled already
10181 auto mz = mouse_z;
10182 bool lclick = mb&1;
10183 bool rclick = mb&2;
10184
10185 if (mb && hotkeys_is_active())
10186 {
10187 hotkeys_toggle_display(false);
10188 while (gui_mouse_b())
10189 {
10190 custom_vsync();
10191 }
10192 return;
10193 }
10194
10195 FONT* tfont = font;
10196 if(zoomed_minimap)
10197 {
10198 if((lclick||rclick) && !minimap_zoomed.rect(x,y))
10199 {
10200 // 'Clicked off'
10201 mmap_set_zoom(false);
10202 goto domouse_doneclick;
10203 }
10204 }
10205
10206 if(real_mb==0)
10207 {
10208 mouse_down = 0;
10209 canfill=true;
10210 }
10211 else if(lclick || rclick)
10212 {
10213 //on the minimap
10214 if(real_mini.rect(x,y))
10215 {
10216 if(lclick)
10217 select_scr();
10218 else if(rclick && !(mouse_down&2))
10219 {
10220 mmap_set_zoom(!zoomed_minimap);
10221 }
10222 goto domouse_doneclick;
10223 }
10224
10225 if(zoomed_minimap && minimap_zoomed.rect(x,y))
10226 goto domouse_doneclick; //Eat clicks
10227
10228 //on the map tabs
10229 font = get_custom_font(CFONT_GUI);
10230 for(int32_t btn=0; btn<mappage_count; ++btn)
10231 {
10232 char tbuf[15];
10233 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
10234 auto& sqr = map_page_bar[btn];
10235 if(sqr.rect(x,y))
10236 {
10237 if(do_layer_button_reset(sqr.x,sqr.y,sqr.w,sqr.h,tbuf,(btn==current_mappage?D_SELECTED:0)))
10238 {
10239 draw_layer_button(screen, sqr.x,sqr.y,sqr.w,sqr.h,tbuf,D_SELECTED);
10240 map_page[current_mappage].map=Map.getCurrMap();
10241 map_page[current_mappage].screen=Map.getCurrScr();
10242 current_mappage=btn;
10243 Map.setCurrMap(map_page[current_mappage].map);
10244 Map.setCurrScr(map_page[current_mappage].screen);
10245 rebuild_trans_table(); //Woo
10246 }
10247 goto domouse_doneclick;
10248 }
10249 }
10250
10251 if(compactbtn.rect(x,y))
10252 {
10253 if(do_text_button(compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact"));
10254 toggle_is_compact();
10255 goto domouse_doneclick;
10256 }
10257
10258 font = get_zc_font(font_lfont_l);
10259 if(combo_merge_btn.rect(x,y))
10260 {
10261 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
10262 if(do_text_button(combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<"))
10263 {
10264 toggle_merged_mode();
10265 }
10266 goto domouse_doneclick;
10267 }
10268
10269 if(favorites_zoombtn.rect(x,y))
10270 {
10271 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
10272 if(do_text_button(favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+"))
10273 {
10274 toggle_favzoom_mode();
10275 }
10276 goto domouse_doneclick;
10277 }
10278 else if(favorites_x.rect(x,y))
10279 {
10280 if(do_text_button(favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X"))
10281 {
10282 AlertDialog("Clear Favorite Combos",
10283 "Are you sure you want to clear all favorite combos?",
10284 [&](bool ret,bool)
10285 {
10286 if(ret)
10287 {
10288 for(auto q = 0; q < MAXFAVORITECOMBOS; ++q)
10289 {
10290 favorite_combos[q] = -1;
10291 favorite_combo_modes[q] = dm_normal;
10292 }
10293 saved = false;
10294 refresh(rFAVORITES);
10295 }
10296 }).show();
10297 }
10298 goto domouse_doneclick;
10299 }
10300 else if(favorites_infobtn.rect(x,y))
10301 {
10302 if(do_text_button(favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?"))
10303 {
10304 InfoDialog("Favorite Combos",
10305 "On LClick (empty): Sets clicked favorite to the current combo."
10306 "\nOn LClick: Sets current combo to clicked favorite."
10307 "\nShift+LClick: Sets clicked favorite to current combo."
10308 "\nCtrl+LClick: Clears clicked favorite."
10309 "\nAlt+LClick: Scrolls to clicked favorite."
10310 "\nRClick: Opens context menu."
10311 "\n\nClick the Page buttons (<-/->) to cycle between pages (RClick to jump to a page)"
10312 "\nClick the Zoom button (+/-) to toggle zoom level."
10313 "\nClick the X button to clear all favorite combos.").show();
10314 }
10315 goto domouse_doneclick;
10316 }
10317 else if(favorites_pgleft.rect(x,y))
10318 {
10319 if (do_text_button(favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-"))
10320 {
10321 if (rclick)
10322 {
10323 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10324 FavoriteComboPage = vbound(*val-1, 0, 8);
10325 }
10326 else
10327 FavoriteComboPage = FavoriteComboPage == 0 ? 8 : --FavoriteComboPage;
10328 reload_zq_gui();
10329 }
10330 goto domouse_doneclick;
10331 }
10332 else if(favorites_pgright.rect(x,y))
10333 {
10334 if (do_text_button(favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->"))
10335 {
10336 if (rclick)
10337 {
10338 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10339 FavoriteComboPage = vbound(*val-1, 0, 8);
10340 }
10341 else
10342 FavoriteComboPage = FavoriteComboPage == 8 ? 0 : ++FavoriteComboPage;
10343 reload_zq_gui();
10344 }
10345 goto domouse_doneclick;
10346 }
10347
10348 if(commands_zoombtn.rect(x,y))
10349 {
10350 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
10351 if(do_text_button(commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+"))
10352 {
10353 toggle_cmdzoom_mode();
10354 }
10355 goto domouse_doneclick;
10356 }
10357 else if(commands_x.rect(x,y))
10358 {
10359 if(do_text_button(commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X"))
10360 {
10361 AlertDialog("Clear Favorite Commands",
10362 "Are you sure you want to clear all favorite commands?",
10363 [&](bool ret,bool)
10364 {
10365 if(ret)
10366 {
10367 char buf[20];
10368 for(auto q = 0; q < MAXFAVORITECOMMANDS; ++q)
10369 {
10370 write_fav_command(q,0);
10371 }
10372 refresh(rFAVORITES);
10373 }
10374 }).show();
10375 }
10376 goto domouse_doneclick;
10377 }
10378 else if(commands_infobtn.rect(x,y))
10379 {
10380 if(do_text_button(commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?"))
10381 {
10382 InfoDialog("Favorite Commands",
10383 "On LClick (empty): Choose a favorite command"
10384 "\nOn LClick: Runs the favorite command"
10385 "\nShift+Click: Choose a favorite command"
10386 "\nRClick: Choose a favorite command"
10387 "\nCtrl+Click: Clears clicked command"
10388 "\nAlt+Click: Shows info on the favorite command"
10389 "\n\nClick the Zoom button (+/-) to toggle zoom level"
10390 "\nClick the X button to clear all favorite commands").show();
10391 }
10392 goto domouse_doneclick;
10393 }
10394 font=tfont;
10395
10396 // On the layer panel
10397 font = get_custom_font(CFONT_GUI);
10398 for(int32_t i=0; i<=6; ++i)
10399 {
10400 int32_t spacing_offs = is_compact ? 2 : 10;
10401 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
10402 int32_t ry = layer_panel.y;
10403
10404 if((i==0 || Map.CurrScr()->layermap[i-1]) && isinRect(x,y,rx,ry,rx+layerpanel_buttonwidth-1,ry+layerpanel_buttonheight-1))
10405 {
10406 char tbuf[15];
10407
10408 if(i!=0 && Map.CurrScr()->layermap[i-1])
10409 {
10410 if(is_compact)
10411 {
10412 sprintf(tbuf, "%s%d %d:%02X",
10413 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10414 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10415 }
10416 else
10417 {
10418 sprintf(tbuf, "%s%d (%d:%02X)",
10419 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10420 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10421 }
10422 }
10423 else
10424 {
10425 sprintf(tbuf, "%d", i);
10426 }
10427
10428 if(do_text_button(rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf))
10429 {
10430 CurrentLayer = i;
10431 goto domouse_doneclick;
10432 }
10433 }
10434
10435 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
10436 if(isinRect(x,y,rx+layerpanel_buttonwidth+1,ry+cbyofs,rx+layerpanel_buttonwidth+1+layerpanel_checkbox_wid-1,ry+2+layerpanel_checkbox_hei-1))
10437 {
10438 do_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]);
10439 goto domouse_doneclick;
10440 }
10441 }
10442 font=tfont;
10443
10444 //Uses lclick/rclick separately
10445
10446 //on the map screen
10447 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreensize)-1,startyint+(176*mapscreensize)-1))
10448 {
10449 if (draw_mode == dm_auto)
10450 {
10451 if (CHECK_CTRL_CMD)
10452 {
10453 if (canfill)
10454 {
10455 switch (fill_type)
10456 {
10457 case 0:
10458 flood();
10459 break;
10460
10461 case 1:
10462 fill_4();
10463 break;
10464
10465 case 2:
10466 fill_8();
10467 break;
10468
10469 case 3:
10470 fill2_4();
10471 break;
10472
10473 case 4:
10474 fill2_8();
10475 break;
10476 }
10477
10478 canfill = false;
10479 }
10480 }
10481 else
10482 draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10483 }
10484 else if(lclick)
10485 {
10486 int32_t cx2 = (x-startxint)/mapscreensize;
10487 int32_t cy2 = (y-startyint)/mapscreensize;
10488
10489 // Move items
10490 if(Map.CurrScr()->hasitem)
10491 {
10492 int32_t ix = Map.CurrScr()->itemx;
10493 int32_t iy = Map.CurrScr()->itemy;
10494
10495 if(cx2 >= ix && cx2 < ix+16 && cy2 >= iy && cy2 < iy+16)
10496 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE,true,0,0,16,16);
10497 }
10498
10499 // Move FFCs
10500 for(int32_t i=MAXFFCS-1; i>=0; i--)
10501 if(Map.CurrScr()->ffcs[i].data !=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffc_overlay)))
10502 {
10503 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
10504 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
10505
10506 if(cx2 >= ffx && cx2 < ffx+(Map.CurrScr()->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(Map.CurrScr()->ffTileHeight(i)*16))
10507 {
10508 moveffc(i,cx2,cy2);
10509 break;
10510 }
10511 }
10512
10513 if(key[KEY_ALT]||key[KEY_ALTGR])
10514 {
10515 int32_t drawmap, drawscr;
10516 if(CurrentLayer==0)
10517 {
10518 drawmap=Map.getCurrMap();
10519 drawscr=Map.getCurrScr();
10520 }
10521 else
10522 {
10523 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
10524 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
10525 }
10526 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
10527 if(!draw_mapscr) return;
10528 Combo=draw_mapscr->data[c];
10529 if(AutoBrush)
10530 BrushWidth = BrushHeight = 1;
10531 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
10532 CSet=draw_mapscr->cset[c];
10533 if(CHECK_CTRL_CMD)
10534 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
10535 }
10536 else if(CHECK_CTRL_CMD)
10537 {
10538 if(canfill)
10539 {
10540 switch(fill_type)
10541 {
10542 case 0:
10543 flood();
10544 break;
10545
10546 case 1:
10547 fill_4();
10548 break;
10549
10550 case 2:
10551 fill_8();
10552 break;
10553
10554 case 3:
10555 fill2_4();
10556 break;
10557
10558 case 4:
10559 fill2_8();
10560 break;
10561 }
10562
10563 canfill=false;
10564 }
10565 }
10566 else draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10567 }
10568 else if(rclick)
10569 {
10570 ComboBrushPause=1;
10571 refresh(rMAP);
10572 restore_mouse();
10573 ComboBrushPause=0;
10574
10575 bool clickedffc = false;
10576 uint32_t earliestfreeffc = MAXFFCS;
10577
10578 // FFC right-click menu
10579 // This loop also serves to find the free ffc with the smallest slot number.
10580 for(int32_t i=MAXFFCS-1; i>=0; i--)
10581 {
10582 auto data = Map.CurrScr()->ffcs[i].data;
10583 if(data==0)
10584 {
10585 if(i < earliestfreeffc)
10586 earliestfreeffc = i;
10587 continue;
10588 }
10589
10590 if(clickedffc || !(Map.CurrScr()->valid&mVALID))
10591 continue;
10592
10593 if(data!=0 && (CurrentLayer<2 || (Map.CurrScr()->ffcs[i].flags&ffc_overlay)))
10594 {
10595 int32_t ffx = Map.CurrScr()->ffcs[i].x.getFloor();
10596 int32_t ffy = Map.CurrScr()->ffcs[i].y.getFloor();
10597 int32_t cx2 = (x-startxint)/mapscreensize;
10598 int32_t cy2 = (y-startyint)/mapscreensize;
10599
10600 if(cx2 >= ffx && cx2 < ffx+(Map.CurrScr()->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(Map.CurrScr()->ffTileHeight(i)*16))
10601 {
10602 NewMenu rcmenu
10603 {
10604 { "Copy FFC", [&](){Map.CopyFFC(i);} },
10605 { "Paste FFC data", [&]()
10606 {
10607 bool didconfirm = false;
10608 AlertDialog("Confirm Paste",
10609 "Really replace the FFC with the data of the copied FFC?",
10610 [&](bool ret,bool)
10611 {
10612 if(ret)
10613 didconfirm = true;
10614 }).show();
10615 if(didconfirm)
10616 {
10617 auto set_ffc_data = Map.getCopyFFCData();
10618 set_ffc_data.x = Map.CurrScr()->ffcs[i].x;
10619 set_ffc_data.y = Map.CurrScr()->ffcs[i].y;
10620 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
10621 }
10622 }, nullopt, Map.getCopyFFC() < 0 },
10623 { "Edit FFC", [&](){call_ffc_dialog(i);} },
10624 { "Clear FFC", [&]()
10625 {
10626 bool didconfirm = false;
10627 AlertDialog("Confirm Clear",
10628 "Really clear this Freeform Combo?",
10629 [&](bool ret,bool)
10630 {
10631 if(ret)
10632 didconfirm = true;
10633 }).show();
10634 if(didconfirm)
10635 {
10636 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, {
10637 .x = 0,
10638 .y = 0,
10639 .vx = 0,
10640 .vy = 0,
10641 .ax = 0,
10642 .ay = 0,
10643 .data = 0,
10644 .cset = 0,
10645 .delay = 0,
10646 .link = 0,
10647 .script = 0,
10648 .tw = 1,
10649 .th = 1,
10650 .ew = 16,
10651 .eh = 16,
10652 .flags = ffc_none,
10653 .inita = 10000,
10654 .initd = 0,
10655 });
10656 saved = false;
10657 }
10658 } },
10659 { "Snap to Grid", [&]()
10660 {
10661 int oldffx = Map.CurrScr()->ffcs[i].x.getInt();
10662 int oldffy = Map.CurrScr()->ffcs[i].y.getInt();
10663 int pos = COMBOPOS(oldffx,oldffy);
10664 int newffy = COMBOY(pos);
10665 int newffx = COMBOX(pos);
10666
10667 auto set_ffc_data = set_ffc_command::create_data(Map.CurrScr()->ffcs[i]);
10668 set_ffc_data.x = newffx;
10669 set_ffc_data.y = newffy;
10670 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), i, set_ffc_data);
10671
10672 saved = false;
10673 } },
10674 };
10675 rcmenu.pop(x, y);
10676 clickedffc = true;
10677 break;
10678 }
10679 }
10680
10681 }
10682
10683 // Combo right-click menu
10684 if(!clickedffc)
10685 {
10686 int warpindex = Map.warpindex(Map.CurrScr()->data[c]);
10687 string txt_twarp_follow, txt_twarp_edit, txt_ffc_edit, txt_ffc_paste;
10688 bool show_ffcs = earliestfreeffc < MAXFFCS;
10689 bool dis_paste_ffc = Map.getCopyFFC() < 0;
10690 bool show_warps = warpindex > -1;
10691 bool show_warpback = Map.has_warpback();
10692 // FFC-specific options
10693 if(earliestfreeffc < MAXFFCS)
10694 {
10695 txt_ffc_edit = fmt::format("Edit New FFC {}",earliestfreeffc+1);
10696 if(Map.getCopyFFC()>-1)
10697 txt_ffc_paste = fmt::format("Paste FFC as FFC {}",earliestfreeffc+1);
10698 else
10699 txt_ffc_paste = "Paste FFC";
10700 }
10701
10702 if(warpindex > -1)
10703 {
10704 char letter = warpindex==4 ? 'R' : 'A'+warpindex;
10705 txt_twarp_follow = fmt::format("Follow Tile Warp {}",letter);
10706 txt_twarp_edit = fmt::format("Edit Tile Warp {}",letter);
10707 }
10708
10709 int32_t drawmap, drawscr;
10710 if(CurrentLayer==0)
10711 {
10712 drawmap=Map.getCurrMap();
10713 drawscr=Map.getCurrScr();
10714 }
10715 else
10716 {
10717 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
10718 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
10719 }
10720 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
10721 NewMenu draw_rc_menu
10722 {
10723 { "Select Combo", [&]()
10724 {
10725 Combo = draw_mapscr->data[c];
10726 if(AutoBrush)
10727 BrushWidth = BrushHeight = 1;
10728 }, nullopt, !draw_mapscr },
10729 { "Scroll to Combo", [&]()
10730 {
10731 First[current_combolist] = scrollto_cmb(draw_mapscr->data[c]);
10732 }, nullopt, !draw_mapscr },
10733 { "Edit Combo", [&]()
10734 {
10735 edit_combo(draw_mapscr->data[c],true,draw_mapscr->cset[c]);
10736 }, nullopt, !draw_mapscr },
10737 {},
10738 { "Replace All", [&](){replace(c);} },
10739 { "Draw Block", &draw_block_menu },
10740 { "Brush Settings ", &brush_menu },
10741 { "Set Fill Type ", &fill_menu },
10742 };
10743 if(show_warps || show_warpback)
10744 {
10745 draw_rc_menu.add_sep();
10746 if(show_warpback)
10747 draw_rc_menu.add({ "Warp Back", [&](){Map.warpback();} });
10748 if(show_warps)
10749 {
10750 draw_rc_menu.add({ txt_twarp_follow, [&](){follow_twarp(warpindex);} });
10751 draw_rc_menu.add({ txt_twarp_edit, [&](){edit_twarp(warpindex);} });
10752 }
10753 }
10754 if(show_ffcs)
10755 {
10756 draw_rc_menu.add_sep();
10757 draw_rc_menu.add({ txt_ffc_edit, [&]()
10758 {
10759 ffdata tempdat;
10760 tempdat.x = (((x-startxint)/mapscreensize)&(~0x0007))*10000;
10761 tempdat.y = (((y-startyint)/mapscreensize)&(~0x0007))*10000;
10762 tempdat.data = Combo;
10763 tempdat.cset = CSet;
10764 call_ffc_dialog(earliestfreeffc, tempdat);
10765 } });
10766 draw_rc_menu.add({ txt_ffc_paste, [&]()
10767 {
10768 auto set_ffc_data = Map.getCopyFFCData();
10769 set_ffc_data.x = (((x-startxint)/mapscreensize)&(~0x0007));
10770 set_ffc_data.y = (((y-startyint)/mapscreensize)&(~0x0007));
10771 Map.DoSetFFCCommand(Map.getCurrMap(), Map.getCurrScr(), earliestfreeffc, set_ffc_data);
10772 }, nullopt, dis_paste_ffc });
10773 }
10774 draw_rc_menu.add_sep();
10775 draw_rc_menu.add({ "Screen", &rc_menu_screen });
10776 draw_rc_menu.pop(x,y);
10777 }
10778 }
10779 goto domouse_doneclick;
10780 }
10781
10782 //on the drawing mode button
10783 font = get_custom_font(CFONT_GUI);
10784 if(drawmode_btn.rect(x,y))
10785 {
10786 if(lclick)
10787 {
10788 if(do_text_button(drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode]))
10789 onDrawingMode();
10790 }
10791 else if(rclick)
10792 drawing_mode_menu.pop(x,y);
10793 goto domouse_doneclick;
10794 }
10795 font=tfont;
10796
10797 //Squares
10798 {
10799 if(squarepanel_swap_btn.rect(x,y))
10800 {
10801 toggle_compact_sqr_mode();
10802 goto domouse_doneclick;
10803 }
10804 if(squarepanel_up_btn.rect(x,y))
10805 {
10806 cycle_compact_sqr(false);
10807 goto domouse_doneclick;
10808 }
10809 if(squarepanel_down_btn.rect(x,y))
10810 {
10811 cycle_compact_sqr(true);
10812 goto domouse_doneclick;
10813 }
10814
10815 bool do_dummyxy = false;
10816 bool dummymode = key[KEY_LSHIFT] || key[KEY_RSHIFT];
10817
10818 if(itemsqr_pos.rect(x,y))
10819 {
10820 if(dummymode) do_dummyxy = true;
10821 else
10822 {
10823 onItem();
10824
10825 if(!rclick && Map.CurrScr()->hasitem)
10826 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE);
10827 goto domouse_doneclick;
10828 }
10829 }
10830
10831 if(stairsqr_pos.rect(x,y))
10832 {
10833 if(dummymode) do_dummyxy = true;
10834 else
10835 {
10836 doxypos(Map.CurrScr()->stairx,Map.CurrScr()->stairy,14,SNAP_WHOLE);
10837 goto domouse_doneclick;
10838 }
10839 }
10840
10841 if(warparrival_pos.rect(x,y))
10842 {
10843 if(dummymode) do_dummyxy = true;
10844 else
10845 {
10846 if(get_qr(qr_NOARRIVALPOINT))
10847 {
10848 info_dsa("Arrival Square",
10849 "The arrival square cannot be used unless the QR 'Use Warp Return "
10850 "Points Only' under 'Quest->Options->Combos' is disabled."
10851 "\nGenerally, this square only exists for compatibility purposes, and is not used"
10852 " in creating new quests.",
10853 "dsa_warparrival");
10854 }
10855 else doxypos(Map.CurrScr()->warparrivalx,Map.CurrScr()->warparrivaly,10,SNAP_HALF,SNAP_NONE);
10856 goto domouse_doneclick;
10857 }
10858 }
10859
10860 if(flagsqr_pos.rect(x,y))
10861 {
10862 if(dummymode) do_dummyxy = true;
10863 else
10864 {
10865 onFlags();
10866 goto domouse_doneclick;
10867 }
10868 }
10869
10870 for(auto q = 0; q < 4; ++q)
10871 {
10872 if(warpret_pos[q].rect(x,y))
10873 {
10874 if(dummymode) do_dummyxy = true;
10875 else
10876 {
10877 doxypos(Map.CurrScr()->warpreturnx[q],Map.CurrScr()->warpreturny[q],9,SNAP_HALF,SNAP_NONE);
10878 goto domouse_doneclick;
10879 }
10880 }
10881 }
10882
10883 if(enemy_prev_pos.rect(x,y))
10884 {
10885 if(dummymode) do_dummyxy = true;
10886 else
10887 {
10888 onEnemies();
10889 goto domouse_doneclick;
10890 }
10891 }
10892
10893 if(do_dummyxy)
10894 {
10895 byte x = 0, y = 0;
10896 showxypos_dummy = true;
10897 doxypos(x,y,13,SNAP_HALF,SNAP_NONE);
10898 goto domouse_doneclick;
10899 }
10900 }
10901
10902 if(draw_mode==dm_alias)
10903 {
10904 for(int32_t j=0; j<num_combo_cols; ++j)
10905 {
10906 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10907 {
10908 scrollup(j);
10909 goto domouse_doneclick;
10910 }
10911 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10912 {
10913 scrolldown(j);
10914 goto domouse_doneclick;
10915 }
10916 else if(comboaliaslist[j].rect(x,y))
10917 {
10918 select_comboa(j);
10919
10920 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10921 popup_cpane_rc(x, y);
10922 goto domouse_doneclick;
10923 }
10924 }
10925 }
10926 else if(draw_mode==dm_cpool)
10927 {
10928 for(int32_t j=0; j<num_combo_cols; ++j)
10929 {
10930 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10931 {
10932 scrollup(j);
10933 goto domouse_doneclick;
10934 }
10935 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10936 {
10937 scrolldown(j);
10938 goto domouse_doneclick;
10939 }
10940 else if(comboaliaslist[j].rect(x,y))
10941 {
10942 select_combop(j);
10943
10944 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10945 popup_cpane_rc(x, y);
10946 goto domouse_doneclick;
10947 }
10948 }
10949 }
10950 else if (draw_mode == dm_auto)
10951 {
10952 for (int32_t j = 0; j < num_combo_cols; ++j)
10953 {
10954 if (combolistscrollers[j].rectind(x, y) == 0 && !mouse_down)
10955 {
10956 scrollup(j);
10957 goto domouse_doneclick;
10958 }
10959 else if (combolistscrollers[j].rectind(x, y) == 1 && !mouse_down)
10960 {
10961 scrolldown(j);
10962 goto domouse_doneclick;
10963 }
10964 else if (comboaliaslist[j].rect(x, y))
10965 {
10966 select_autocombo(j);
10967
10968 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10969 popup_cpane_rc(x, y);
10970 goto domouse_doneclick;
10971 }
10972 }
10973 }
10974 else
10975 {
10976 for(int32_t j=0; j<num_combo_cols; ++j)
10977 {
10978 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10979 {
10980 scrollup(j);
10981 goto domouse_doneclick;
10982 }
10983 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10984 {
10985 scrolldown(j);
10986 goto domouse_doneclick;
10987 }
10988 else if(combolist[j].rect(x,y))
10989 {
10990 select_combo(j);
10991
10992 if(rclick && combolist[j].rect(gui_mouse_x(),gui_mouse_y()))
10993 popup_cpane_rc(x, y);
10994 goto domouse_doneclick;
10995 }
10996 }
10997 }
10998
10999 //on the favorites list
11000 if(favorites_list.rect(x,y))
11001 {
11002 if(lclick)
11003 {
11004 int32_t f=favorites_list.rectind(x,y);
11005 int32_t row=f/favorites_list.w;
11006 int32_t col=f%favorites_list.w;
11007 f = (row*FAVORITECOMBO_PER_ROW)+col;
11008 int32_t fp = f + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
11009
11010 bool dmcond = favorite_combos[fp] < 0;
11011 if((key[KEY_LSHIFT] || key[KEY_RSHIFT] || dmcond) && !(CHECK_CTRL_CMD))
11012 {
11013 int32_t tempcb=ComboBrush;
11014 ComboBrush=0;
11015
11016 while(gui_mouse_b())
11017 {
11018 x=gui_mouse_x();
11019 y=gui_mouse_y();
11020
11021 switch(draw_mode)
11022 {
11023 case dm_alias:
11024 if (favorite_combos[fp] != combo_apos || favorite_combo_modes[fp] != dm_alias)
11025 {
11026 favorite_combo_modes[fp] = dm_alias;
11027 favorite_combos[fp] = combo_apos;
11028 saved = false;
11029 }
11030 break;
11031 case dm_cpool:
11032 if (favorite_combos[fp] != combo_pool_pos || favorite_combo_modes[fp] != dm_cpool)
11033 {
11034 favorite_combo_modes[fp] = dm_cpool;
11035 favorite_combos[fp] = combo_pool_pos;
11036 saved = false;
11037 }
11038 break;
11039 case dm_auto:
11040 if (favorite_combos[fp] != combo_auto_pos || favorite_combo_modes[fp] != dm_auto)
11041 {
11042 favorite_combo_modes[fp] = dm_auto;
11043 favorite_combos[fp] = combo_auto_pos;
11044 saved = false;
11045 }
11046 break;
11047 default:
11048 if (favorite_combos[fp] != Combo || favorite_combo_modes[fp] != dm_normal)
11049 {
11050 if (BrushWidth > 1 || BrushHeight > 1)
11051 {
11052 add_favorite_combo_block(f, Combo, key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11053 break;
11054 }
11055 favorite_combo_modes[fp] = dm_normal;
11056 favorite_combos[fp] = Combo;
11057 saved = false;
11058 }
11059 }
11060
11061 custom_vsync();
11062 refresh(rALL | rFAVORITES);
11063 }
11064
11065 ComboBrush=tempcb;
11066 }
11067 else if(CHECK_CTRL_CMD)
11068 {
11069 int32_t tempcb=ComboBrush;
11070 ComboBrush=0;
11071
11072 while(gui_mouse_b())
11073 {
11074 x=gui_mouse_x();
11075 y=gui_mouse_y();
11076
11077 if(favorite_combos[fp]!=-1)
11078 {
11079 favorite_combo_modes[fp] = dm_normal;
11080 favorite_combos[fp]=-1;
11081 saved=false;
11082 }
11083
11084 custom_vsync();
11085 refresh(rALL | rFAVORITES);
11086 }
11087
11088 ComboBrush=tempcb;
11089 }
11090 else if(key[KEY_ALT] || key[KEY_ALTGR])
11091 {
11092 if(select_favorite())
11093 {
11094 switch(favorite_combo_modes[fp])
11095 {
11096 case dm_alias:
11097 combo_alistpos[current_comboalist]=scrollto_alias(combo_apos);
11098 break;
11099 case dm_cpool:
11100 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
11101 break;
11102 case dm_auto:
11103 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
11104 break;
11105 default:
11106 First[current_combolist]=scrollto_cmb(Combo);
11107 }
11108 }
11109 }
11110 else
11111 {
11112 select_favorite();
11113 }
11114 }
11115 else if(rclick)
11116 {
11117 bool valid=select_favorite();
11118
11119 if(valid)
11120 {
11121 int f = favorites_list.rectind(x,y);
11122 int row = f/favorites_list.w;
11123 int col = f%favorites_list.w;
11124 f = (row*FAVORITECOMBO_PER_ROW) + col + (FAVORITECOMBO_PER_PAGE * FavoriteComboPage);
11125 popup_favorites_rc(f, x, y);
11126 }
11127 }
11128 goto domouse_doneclick;
11129 }
11130
11131 //on the commands buttons
11132 int32_t cmd = commands_list.rectind(x,y);
11133 if(cmd > -1)
11134 {
11135 uint hkey = favorite_commands[cmd];
11136 bool shift=(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11137 bool ctrl=(CHECK_CTRL_CMD);
11138 bool alt=(key[KEY_ALT] || key[KEY_ALTGR]);
11139 bool dis = disabled_hotkey(hkey);
11140 auto& btn = commands_list.subsquare(cmd);
11141 if(!dis||rclick||shift||ctrl||alt)
11142 {
11143 FONT *tfont=font;
11144 font=get_custom_font(CFONT_FAVCMD);
11145 if(do_layer_button_reset(btn.x,btn.y,btn.w,btn.h,
11146 get_hotkey_name(hkey),
11147 selected_hotkey(hkey)?D_SELECTED:0,
11148 true))
11149 {
11150 font=tfont;
11151 if(alt)
11152 {
11153 show_hotkey_info(hkey);
11154 }
11155 else if(ctrl)
11156 {
11157 write_fav_command(cmd,0);
11158 }
11159 else if(rclick || shift || hkey==ZQKEY_NULL_KEY)
11160 {
11161 if(auto newkey = select_fav_command())
11162 write_fav_command(cmd,*newkey);
11163 }
11164 else
11165 {
11166 run_hotkey(hkey);
11167 }
11168 }
11169
11170 font=tfont;
11171 }
11172 goto domouse_doneclick;
11173 }
11174 }
11175
11176 domouse_doneclick:
11177 mouse_down |= mb&3;
11178
11179 if(mouse_z!=0)
11180 {
11181 int32_t z=0;
11182
11183 for(int32_t j=0; j<num_combo_cols; ++j)
11184 {
11185 z=abs(mouse_z);
11186
11187 if(key[KEY_ALT]||key[KEY_ALTGR])
11188 {
11189 z*=combolist[j].h;
11190 }
11191
11192
11193 if(draw_mode == dm_alias)
11194 {
11195 if(comboaliaslist[j].rect(x,y))
11196 {
11197 if(mouse_z<0) //scroll down
11198 {
11199 combo_alistpos[current_comboalist] = zc_min(MAXCOMBOALIASES - comboaliaslist[j].w*comboaliaslist[j].h,
11200 combo_alistpos[current_comboalist]+comboaliaslist[j].w*z);
11201 }
11202 else //scroll up
11203 {
11204 if(combo_alistpos[current_comboalist]>0)
11205 {
11206 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],comboaliaslist[j].w*z);
11207 }
11208 }
11209 goto domouse_donez;
11210 }
11211 }
11212 else if(draw_mode == dm_cpool)
11213 {
11214 if(comboaliaslist[j].rect(x,y))
11215 {
11216 if(mouse_z<0) //scroll down
11217 {
11218 combo_pool_listpos[current_cpoollist] = zc_min(MAXCOMBOPOOLS - comboaliaslist[j].w*comboaliaslist[j].h,
11219 combo_pool_listpos[current_cpoollist]+comboaliaslist[j].w*z);
11220 }
11221 else //scroll up
11222 {
11223 if(combo_pool_listpos[current_cpoollist]>0)
11224 {
11225 combo_pool_listpos[current_cpoollist]-=zc_min(combo_pool_listpos[current_cpoollist],comboaliaslist[j].w*z);
11226 }
11227 }
11228 goto domouse_donez;
11229 }
11230 }
11231 else if (draw_mode == dm_auto)
11232 {
11233 if (comboaliaslist[j].rect(x, y))
11234 {
11235 if (mouse_z < 0) //scroll down
11236 {
11237 combo_auto_listpos[current_cautolist] = zc_min(MAXAUTOCOMBOS - comboaliaslist[j].w * comboaliaslist[j].h,
11238 combo_auto_listpos[current_cautolist] + comboaliaslist[j].w * z);
11239 }
11240 else //scroll up
11241 {
11242 if (combo_auto_listpos[current_cautolist] > 0)
11243 {
11244 combo_auto_listpos[current_cautolist] -= zc_min(combo_auto_listpos[current_cautolist], comboaliaslist[j].w * z);
11245 }
11246 }
11247 goto domouse_donez;
11248 }
11249 }
11250 else
11251 {
11252 if(combolist[j].rect(x,y))
11253 {
11254 if(mouse_z<0) //scroll down
11255 {
11256 First[current_combolist] = zc_min(MAXCOMBOS-combolist[j].w*combolist[j].h,
11257 First[current_combolist] + combolist[j].w*z);
11258 }
11259 else //scroll up
11260 {
11261 if(First[current_combolist]>0)
11262 {
11263 First[current_combolist]-=zc_min(First[current_combolist],combolist[j].w*z);
11264 }
11265 }
11266 goto domouse_donez;
11267 }
11268 }
11269 }
11270
11271 z=abs(mouse_z);
11272
11273 if(real_mini.rect(x,y))
11274 {
11275 for(int32_t i=0; i<z; ++i)
11276 {
11277 if(mouse_z>0) onIncMap();
11278 else onDecMap();
11279 }
11280 goto domouse_donez;
11281 }
11282
11283 if(is_compact && compact_square_panels
11284 && squares_panel.rect(x,y))
11285 {
11286 cycle_compact_sqr(mouse_z < 0);
11287 goto domouse_donez;
11288 }
11289 domouse_donez:
11290 position_mouse_z(0);
11291 }
11292 font = tfont;
11293 }
11294
11295 int32_t d_viewpal_proc(int32_t msg, DIALOG *d, int32_t c)
11296 {
11297 int32_t ret = d_bitmap_proc(msg, d, c);
11298 char* buf = (char*)d->dp2; //buffer to store the color code in
11299 DIALOG* d2 = (DIALOG*)d->dp3; //DIALOG* to update the text proc
11300 if(!buf)
11301 return ret;
11302 switch(msg)
11303 {
11304 case MSG_IDLE:
11305 case MSG_GOTMOUSE:
11306 case MSG_LOSTMOUSE:
11307 break;
11308 default:
11309 return ret;
11310 }
11311 char t[16];
11312 memcpy(t, buf, 16);
11313 int32_t x = gui_mouse_x() - d->x;
11314 int32_t y = gui_mouse_y() - d->y;
11315 if(msg != MSG_LOSTMOUSE && isinRect(x, y, 0, 0, d->w-1, d->h-1))
11316 {
11317 float palscale = 1.5;
11318 for(int32_t i = 0; i<256; ++i)
11319 if(isinRect(x,y,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale)))
11320 {
11321 sprintf(buf, "0x%02X (%03d) ", i, i); //Extra spaces to increase drawn width, so it draws the blank area
11322 break;
11323 }
11324 }
11325 else memset(buf, ' ', 15);
11326 if(strcmp(buf, t) && d2 && d2->proc == jwin_text_proc && d2->dp == d->dp2)
11327 object_message(d2, MSG_DRAW, 0);
11328 return ret;
11329 }
11330
11331 static DIALOG showpal_dlg[] =
11332 {
11333 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11334 { jwin_win_proc, 24, 68, 272, 119, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Palette", NULL, NULL },
11335 { jwin_frame_proc, 30, 76+16, 260, 68, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11336 { d_viewpal_proc, 32, 76+18, 256, 64, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11337 { jwin_text_proc, 32+8,76+18+66, 20, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11338 { jwin_button_proc, 130, 144+18, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11339 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11340 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11341 };
11342
11343 int32_t onShowPal()
11344 {
11345 float palscale = 1.5;
11346
11347 BITMAP *palbmp = create_bitmap_ex(8,(int32_t)(256*palscale),(int32_t)(64*palscale));
11348
11349 if(!palbmp)
11350 return D_O_K;
11351 clear_to_color(palbmp,jwin_pal[jcBOX]); //If not cleared, random static appears between swatches! -E
11352 showpal_dlg[0].dp2=get_zc_font(font_lfont);
11353
11354 for(int32_t i=0; i<256; i++)
11355 rectfill(palbmp,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale),i);
11356 showpal_dlg[2].dp=(void *)palbmp;
11357 char buf[16] = {0};
11358 showpal_dlg[2].dp2=(void *)buf;
11359 showpal_dlg[2].dp3=(void *)&(showpal_dlg[3]);
11360 showpal_dlg[3].dp=(void *)buf;
11361 showpal_dlg[3].dp2=(void *)get_zc_font(font_deffont);
11362
11363 large_dialog(showpal_dlg);
11364 do_zqdialog(showpal_dlg,2);
11365 destroy_bitmap(palbmp);
11366 return D_O_K;
11367 }
11368
11369 static DIALOG csetfix_dlg[] =
11370 {
11371 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11372 { jwin_win_proc, 72, 80, 176+1, 96+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "CSet Fix", NULL, NULL },
11373 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11374 { jwin_radio_proc, 104+22, 108, 80+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full Screen", NULL, NULL },
11375 { jwin_radio_proc, 104+22, 118+2, 80+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Dungeon Floor", NULL, NULL },
11376 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
11377 { jwin_check_proc, 104+22, 128+4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "All Layers", NULL, NULL },
11378 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11379 { jwin_button_proc, 170, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11380 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11381 };
11382
11383 int32_t onCSetFix()
11384 {
11385 restore_mouse();
11386 csetfix_dlg[0].dp2=get_zc_font(font_lfont);
11387 int32_t s=2,x2=14,y2=9;
11388
11389 large_dialog(csetfix_dlg);
11390
11391 if(do_zqdialog(csetfix_dlg,-1)==6)
11392 {
11393 if(csetfix_dlg[2].flags&D_SELECTED)
11394 {
11395 s=0;
11396 x2=16;
11397 y2=11;
11398 }
11399
11400 if(csetfix_dlg[5].flags&D_SELECTED)
11401 {
11402 /*
11403 int32_t drawmap, drawscr;
11404 if (CurrentLayer==0)
11405 {
11406 drawmap=Map.getCurrMap();
11407 drawscr=Map.getCurrScr();
11408 }
11409 else
11410 {
11411 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
11412 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
11413 }
11414 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
11415 if(!draw_mapscr) return;
11416 saved=false;
11417 Map.Ugo();
11418
11419 if(!(draw_mapscr->valid&mVALID))
11420 {
11421 Map.CurrScr()->valid|=mVALID;
11422 draw_mapscr->valid|=mVALID;
11423 Map.setcolor(Color);
11424 }
11425 for(int32_t i=0; i<176; i++)
11426 {
11427 draw_mapscr->data[i]=Combo;
11428 draw_mapscr->cset[i]=CSet;
11429 }
11430 refresh(rMAP+rSCRMAP);
11431 */
11432 }
11433
11434 Map.StartListCommand();
11435 for(int32_t y=s; y<y2; y++)
11436 {
11437 for(int32_t x=s; x<x2; x++)
11438 {
11439 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (y<<4)+x, -1, CSet);
11440 }
11441 }
11442 Map.FinishListCommand();
11443
11444 refresh(rMAP);
11445 saved = false;
11446 }
11447
11448 return D_O_K;
11449 }
11450 static bool doAllSolidWater()
11451 {
11452 for(int32_t i=0; i < MAXCOMBOS; ++i)
11453 {
11454 if(combo_class_buf[combobuf[i].type].water!=0)
11455 {
11456 combobuf[i].walk |= 0x0F; //Solid
11457 }
11458 }
11459 return true;
11460 }
11461 static bool doNoSolidWater()
11462 {
11463 for(int32_t i=0; i < MAXCOMBOS; ++i)
11464 {
11465 if(combo_class_buf[combobuf[i].type].water!=0)
11466 {
11467 combobuf[i].walk &= ~0x0F; //Non-solid
11468 }
11469 }
11470 return true;
11471 }
11472 int32_t onWaterSolidity()
11473 {
11474 AlertFuncDialog("Water Conversion",
11475 "Forcibly set the solidity of all 'Liquid' combos in the quest?",
11476 "",
11477 3, 2, //3 buttons, where buttons[2] is focused
11478 { "Solid", "Non-Solid", "Cancel" },
11479 { doAllSolidWater, doNoSolidWater, nullptr }
11480 ).show();
11481 return D_O_K;
11482 }
11483
11484 static bool doAllEffectSquare()
11485 {
11486 for(int32_t i=0; i < MAXCOMBOS; ++i)
11487 {
11488 combobuf[i].walk |= 0xF0; //Effect
11489 }
11490 return true;
11491 }
11492 static bool doBlankEffectSquare()
11493 {
11494 for(int32_t i=0; i < MAXCOMBOS; ++i)
11495 {
11496 if(combobuf[i].is_blank(true))
11497 {
11498 combobuf[i].walk |= 0xF0; //Effect
11499 }
11500 }
11501 return true;
11502 }
11503
11504 int32_t onEffectFix()
11505 {
11506 AlertFuncDialog("Effect Square Conversion",
11507 "Forcibly fill the green effect square of all combos in the quest?",
11508 "",
11509 3, 2, //3 buttons, where buttons[2] is focused
11510 { "All", "Blank Only", "Cancel" },
11511 { doAllEffectSquare, doBlankEffectSquare, nullptr }
11512 ).show();
11513 return D_O_K;
11514 }
11515
11516 byte* getPalPointer(int32_t pal, int32_t cset)
11517 {
11518 if (pal < 0) return colordata + CSET(cset)*3;
11519 byte* ret = colordata + CSET(pal*pdLEVEL+poLEVEL)*3;
11520 switch(cset)
11521 {
11522 case 2: case 3: case 4:
11523 return ret + CSET(cset-2)*3;
11524 case 9:
11525 return ret + CSET(3)*3;
11526 case 1:
11527 return ret + CSET(13)*3;
11528 case 5:
11529 return ret + CSET(14)*3;
11530 case 7:
11531 return ret + CSET(15)*3;
11532 case 8:
11533 return ret + CSET(16)*3;
11534 }
11535 return NULL;
11536 }
11537
11538 void copyCSet(int32_t destpal, int32_t destcset, int32_t srcpal, int32_t srccset)
11539 {
11540 byte* dest = getPalPointer(destpal, destcset);
11541 byte* src = getPalPointer(srcpal, srccset);
11542 if (dest && src)
11543 {
11544 memcpy(dest, src, 16*3);
11545 }
11546 }
11547
11548 void setColorPalette(int32_t flags, int32_t lowpal, int32_t highpal)
11549 {
11550 for (auto q = lowpal; q <= highpal; ++q)
11551 {
11552 for (auto c = 0; c < 12; ++c)
11553 {
11554 if (!(flags&(1<<c))) continue;
11555 copyCSet(q, c, -1, c);
11556 }
11557 }
11558 }
11559
11560 void setPitDamage(int32_t flags, int32_t lowcombo, int32_t highcombo, int32_t damage)
11561 {
11562 for(int32_t i=lowcombo; i < highcombo; ++i)
11563 {
11564 if((combobuf[i].type == cPITFALL && (flags & (1<<0)))
11565 || (combobuf[i].type == cWATER && !(combobuf[i].usrflags & (1<<0)) && (flags & (1<<1)))
11566 || (combobuf[i].type == cWATER && (combobuf[i].usrflags & (1<<0)) && (flags & (1<<2))))
11567 {
11568 if ((combobuf[i].type != cPITFALL || (flags & (1<<9)) || !(combobuf[i].usrflags & (1<<0)))
11569 && ((flags & (1<<8)) || combobuf[i].attributes[0] == 0))
11570 combobuf[i].attributes[0] = damage*10000;
11571 }
11572 }
11573 }
11574
11575 static DIALOG template_dlg[] =
11576 {
11577 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11578 { jwin_win_proc, 72, 80, 176+1, 116+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "NES Dungeon Template", NULL, NULL },
11579 { d_comboframe_proc, 178, 122+3, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11580 { d_combo_proc, 180, 124+3, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11581 // { d_bitmap_proc, 180, 104, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11582 { jwin_radio_proc, 104+33, 128+3, 64+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Floor:", NULL, NULL },
11583 { jwin_radio_proc, 104+33, 148+3, 64+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "No Floor", NULL, NULL },
11584 { jwin_button_proc, 90, 172, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11585 { jwin_button_proc, 170, 172, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11586 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11587 { jwin_text_proc, 104, 102, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "This copies the contents of", NULL, NULL },
11588 { jwin_text_proc, 104, 112, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "screen 83 of the current map.", NULL, NULL },
11589 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11590 };
11591
11592 int32_t onTemplate()
11593 {
11594 static bool donethis=false;
11595
11596 if(!donethis||!(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
11597 {
11598 template_dlg[2].d1=Combo;
11599 template_dlg[2].fg=CSet;
11600 donethis=true;
11601 }
11602
11603 restore_mouse();
11604
11605 if(Map.getCurrScr()==TEMPLATE)
11606 return D_O_K;
11607
11608 // BITMAP *floor_bmp = create_bitmap_ex(8,16,16);
11609 // if(!floor_bmp) return D_O_K;
11610 template_dlg[0].dp2=get_zc_font(font_lfont);
11611 // put_combo(floor_bmp,0,0,Combo,CSet,0,0);
11612 // template_dlg[2].dp=floor_bmp;
11613
11614 large_dialog(template_dlg);
11615
11616 if(do_zqdialog(template_dlg,-1)==5)
11617 {
11618 saved=false;
11619 Map.DoTemplateCommand((template_dlg[3].flags==D_SELECTED) ? template_dlg[2].d1 : -1, template_dlg[2].fg, Map.getCurrScr());
11620 refresh(rMAP+rSCRMAP);
11621 }
11622
11623 // destroy_bitmap(floor_bmp);
11624 return D_O_K;
11625 }
11626
11627 static DIALOG cpage_dlg[] =
11628 {
11629 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11630 { jwin_win_proc, 72, 20, 176+1, 212+1, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11631 { d_ctext2_proc, 160, 28, 0, 8, vc(15), vc(1), 0, 0, 0, 0, (void *) "Combo Page", NULL, NULL },
11632 { jwin_button_proc, 90, 182, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
11633 { jwin_button_proc, 170, 182, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
11634 { jwin_button_proc, 90, 210, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
11635 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
11636 // 6
11637 { jwin_radio_proc, 76, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "0" , NULL, NULL },
11638 { jwin_radio_proc, 76, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1" , NULL, NULL },
11639 { jwin_radio_proc, 76, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "2" , NULL, NULL },
11640 { jwin_radio_proc, 76, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "3" , NULL, NULL },
11641 { jwin_radio_proc, 76, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "4" , NULL, NULL },
11642 { jwin_radio_proc, 76, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "5" , NULL, NULL },
11643 { jwin_radio_proc, 76, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "6" , NULL, NULL },
11644 { jwin_radio_proc, 76, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "7" , NULL, NULL },
11645 { jwin_radio_proc, 76, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "8" , NULL, NULL },
11646 { jwin_radio_proc, 76, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "9" , NULL, NULL },
11647 { jwin_radio_proc, 76, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "10" , NULL, NULL },
11648 { jwin_radio_proc, 76, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "11" , NULL, NULL },
11649 { jwin_radio_proc, 76, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "12" , NULL, NULL },
11650 { jwin_radio_proc, 76, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "13" , NULL, NULL },
11651 { jwin_radio_proc, 76, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "14" , NULL, NULL },
11652 { jwin_radio_proc, 76, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "15" , NULL, NULL },
11653 { jwin_radio_proc, 120, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "16" , NULL, NULL },
11654 { jwin_radio_proc, 120, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "17" , NULL, NULL },
11655 { jwin_radio_proc, 120, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "18" , NULL, NULL },
11656 { jwin_radio_proc, 120, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "19" , NULL, NULL },
11657 { jwin_radio_proc, 120, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "20" , NULL, NULL },
11658 { jwin_radio_proc, 120, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "21" , NULL, NULL },
11659 { jwin_radio_proc, 120, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "22" , NULL, NULL },
11660 { jwin_radio_proc, 120, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "23" , NULL, NULL },
11661 { jwin_radio_proc, 120, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "24" , NULL, NULL },
11662 { jwin_radio_proc, 120, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "25" , NULL, NULL },
11663 { jwin_radio_proc, 120, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "26" , NULL, NULL },
11664 { jwin_radio_proc, 120, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "27" , NULL, NULL },
11665 { jwin_radio_proc, 120, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "28" , NULL, NULL },
11666 { jwin_radio_proc, 120, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "29" , NULL, NULL },
11667 { jwin_radio_proc, 120, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "30" , NULL, NULL },
11668 { jwin_radio_proc, 120, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "31" , NULL, NULL },
11669 { jwin_radio_proc, 164, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "32" , NULL, NULL },
11670 { jwin_radio_proc, 164, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "33" , NULL, NULL },
11671 { jwin_radio_proc, 164, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "34" , NULL, NULL },
11672 { jwin_radio_proc, 164, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "35" , NULL, NULL },
11673 { jwin_radio_proc, 164, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "36" , NULL, NULL },
11674 { jwin_radio_proc, 164, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "37" , NULL, NULL },
11675 { jwin_radio_proc, 164, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "38" , NULL, NULL },
11676 { jwin_radio_proc, 164, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "39" , NULL, NULL },
11677 { jwin_radio_proc, 164, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "40" , NULL, NULL },
11678 { jwin_radio_proc, 164, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "41" , NULL, NULL },
11679 { jwin_radio_proc, 164, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "42" , NULL, NULL },
11680 { jwin_radio_proc, 164, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "43" , NULL, NULL },
11681 { jwin_radio_proc, 164, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "44" , NULL, NULL },
11682 { jwin_radio_proc, 164, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "45" , NULL, NULL },
11683 { jwin_radio_proc, 164, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "46" , NULL, NULL },
11684 { jwin_radio_proc, 164, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "47" , NULL, NULL },
11685 { jwin_radio_proc, 208, 44, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "48" , NULL, NULL },
11686 { jwin_radio_proc, 208, 52, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "49" , NULL, NULL },
11687 { jwin_radio_proc, 208, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "50" , NULL, NULL },
11688 { jwin_radio_proc, 208, 68, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "51" , NULL, NULL },
11689 { jwin_radio_proc, 208, 76, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "52" , NULL, NULL },
11690 { jwin_radio_proc, 208, 84, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "53" , NULL, NULL },
11691 { jwin_radio_proc, 208, 92, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "54" , NULL, NULL },
11692 { jwin_radio_proc, 208, 100, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "55" , NULL, NULL },
11693 { jwin_radio_proc, 208, 108, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "56" , NULL, NULL },
11694 { jwin_radio_proc, 208, 116, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "57" , NULL, NULL },
11695 { jwin_radio_proc, 208, 124, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "58" , NULL, NULL },
11696 { jwin_radio_proc, 208, 132, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "59" , NULL, NULL },
11697 { jwin_radio_proc, 208, 140, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "60" , NULL, NULL },
11698 { jwin_radio_proc, 208, 148, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "61" , NULL, NULL },
11699 { jwin_radio_proc, 208, 156, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "62" , NULL, NULL },
11700 { jwin_radio_proc, 208, 164, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "63" , NULL, NULL },
11701 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11702 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11703 };
11704
11705 int32_t onComboPage()
11706 {
11707 for(int32_t i=0; i<64; i++)
11708 cpage_dlg[i+6].flags = Map.CurrScr()->old_cpage==i?D_SELECTED:0;
11709
11710 int32_t ret = do_zqdialog(cpage_dlg,3);
11711
11712 int32_t p = 0;
11713
11714 for(int32_t i=0; i<64; i++)
11715
11716 if(cpage_dlg[i+6].flags==D_SELECTED)
11717 p=i;
11718
11719 if(ret==2)
11720 {
11721 saved=false;
11722 Map.CurrScr()->old_cpage = p;
11723 }
11724
11725 if(ret==4 && jwin_alert("Confirm Overwrite","Set all combo pages","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
11726 {
11727 saved=false;
11728
11729 for(int32_t i=0; i<=TEMPLATE; i++)
11730 Map.Scr(i)->old_cpage = p;
11731 }
11732
11733 refresh(rALL);
11734 return D_O_K;
11735 }
11736
11737 int32_t d_sel_scombo_proc(int32_t msg, DIALOG *d, int32_t c)
11738 {
11739 //these are here to bypass compiler warnings about unused arguments
11740 c=c;
11741
11742 switch(msg)
11743 {
11744 case MSG_CLICK:
11745 while(gui_mouse_b())
11746 {
11747 int32_t x = zc_min(zc_max(gui_mouse_x() - d->x,0)>>4, 15);
11748 int32_t y = zc_min(zc_max(gui_mouse_y() - d->y,0)&0xF0, 160);
11749
11750 if(x+y != d->d1)
11751 {
11752 d->d1 = x+y;
11753 custom_vsync();
11754 d_sel_scombo_proc(MSG_DRAW,d,0);
11755 }
11756 }
11757
11758 break;
11759
11760 case MSG_DRAW:
11761 {
11762 blit((BITMAP*)(d->dp),screen,0,0,d->x,d->y,d->w,d->h);
11763 int32_t x = d->x + (((d->d1)&15)<<4);
11764 int32_t y = d->y + ((d->d1)&0xF0);
11765 rect(screen,x,y,x+15,y+15,vc(15));
11766 }
11767 break;
11768 }
11769
11770 return D_O_K;
11771 }
11772
11773 /*
11774 static DIALOG sel_scombo_dlg[] =
11775 {
11776 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11777 { jwin_win_proc, 24, 16, 272+1, 216+1, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11778 { d_sel_scombo_proc, 32, 24, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11779 { jwin_button_proc, 90, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11780 { jwin_button_proc, 170, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11781 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11782 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11783 };
11784
11785 void select_scombo(int32_t &pos)
11786 {
11787 go();
11788 Map.draw_template2(screen2,0,0);
11789 sel_scombo_dlg[1].dp = screen2;
11790 sel_scombo_dlg[1].d1 = pos;
11791
11792 while (gui_mouse_b()) {
11793 //nothing
11794 }
11795
11796 if(do_zqdialog(sel_scombo_dlg,3)==2)
11797 pos = sel_scombo_dlg[1].d1;
11798
11799 comeback();
11800 }
11801 */
11802
11803 static DIALOG cflag_dlg[] =
11804 {
11805 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11806 9 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11807 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11808 9 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11809 9 { jwin_button_proc, 70, 163, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11810 9 { jwin_button_proc, 190, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11811 9 { jwin_button_proc, 130, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
11812 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11813 };
11814
11815
11816 void questrev_help()
11817 {
11818 jwin_alert("Help","The revision number of your quest.",NULL,NULL,"O&K",NULL,'k',16,get_zc_font(font_lfont));
11819 }
11820
11821 void questminrev_help()
11822 {
11823 jwin_alert("Help","If a player's saved game was from a revision less than the minimum", "revision, they have to restart from the beginning.", "This is useful if you make major changes to your quest.","O&K",NULL,'k',16,get_zc_font(font_lfont));
11824 }
11825
11826 int32_t select_cflag(const char *prompt,int32_t flag)
11827 {
11828 cflag_dlg[0].dp=(void *)prompt;
11829 cflag_dlg[0].dp2=get_zc_font(font_lfont);
11830 GUI::ListData ld = GUI::ZCListData::mapflag(numericalFlags, true);
11831 ListData select_cflag_list = ld.getJWin(&font);
11832 int32_t index = ld.findIndex(flag);
11833 cflag_dlg[2].d1=index;
11834 cflag_dlg[2].dp=(void *) &select_cflag_list;
11835
11836 large_dialog(cflag_dlg);
11837
11838 int32_t ret;
11839
11840 do
11841 {
11842 ret=do_zqdialog(cflag_dlg,2);
11843
11844 if(ret==5)
11845 {
11846 cflag_help(ld.getValue(cflag_dlg[2].d1));
11847 }
11848 }
11849 while(ret==5);
11850
11851 if(ret==0||ret==4)
11852 {
11853 position_mouse_z(0);
11854 return -1;
11855 }
11856
11857 return ld.getValue(cflag_dlg[2].d1);
11858 }
11859
11860 int32_t select_flag(int32_t &f)
11861 {
11862 int32_t ret=select_cflag("Flag Type",f);
11863
11864 if(ret>=0)
11865 {
11866 f=ret;
11867 return true;
11868 }
11869
11870 return false;
11871 }
11872
11873 int32_t d_scombo_proc(int32_t msg,DIALOG *d,int32_t c)
11874 {
11875 //these are here to bypass compiler warnings about unused arguments
11876 c=c;
11877
11878 switch(msg)
11879 {
11880 case MSG_CLICK:
11881 {
11882 int32_t c2=d->d1;
11883 int32_t cs=d->fg;
11884 int32_t f=d->d2;
11885
11886 if(d->bg==1 || (CHECK_CTRL_CMD))
11887 {
11888 while(gui_mouse_b())
11889 {
11890 /* do nothing */
11891 rest(1);
11892 }
11893
11894 if(select_flag(f))
11895 {
11896 d->d2=f;
11897
11898 }
11899 }
11900 else if(key[KEY_LSHIFT])
11901 {
11902 if(gui_mouse_b()&1)
11903 {
11904 d->d1++;
11905
11906 if(d->d1>=MAXCOMBOS) d->d1=0;
11907 }
11908 else if(gui_mouse_b()&2)
11909 {
11910 d->d1--;
11911
11912 if(d->d1<0) d->d1=MAXCOMBOS-1;
11913 }
11914 }
11915 else if(key[KEY_RSHIFT])
11916 {
11917 if(gui_mouse_b()&1)
11918 {
11919 d->fg++;
11920
11921 if(d->fg>11) d->fg=0;
11922 }
11923 else if(gui_mouse_b()&2)
11924 {
11925 d->fg--;
11926
11927 if(d->fg<0) d->fg=11;
11928 }
11929 }
11930 else if(key[KEY_ALT])
11931 {
11932 if(gui_mouse_b()&1)
11933 {
11934 d->d1 = Combo;
11935 d->fg = CSet;
11936 }
11937 }
11938 else
11939 {
11940 if(select_combo_2(c2, cs))
11941 {
11942 d->d1=c2;
11943 d->fg=cs;
11944 }
11945 }
11946
11947 return D_REDRAW;
11948 }
11949 break;
11950
11951 case MSG_DRAW:
11952 d->w = 32;
11953 d->h = 32;
11954
11955 BITMAP *buf = create_bitmap_ex(8,16,16);
11956 BITMAP *bigbmp = create_bitmap_ex(8,d->w,d->h);
11957
11958 if(buf && bigbmp)
11959 {
11960 clear_bitmap(buf);
11961
11962 if(d->bg) //flags only
11963 {
11964 put_flag(buf,0,0,d->d2);
11965 }
11966 else if(d->d1)
11967 {
11968 putcombo(buf,0,0,d->d1,d->fg);
11969
11970 if(Flags&cFLAGS)
11971 put_flags(buf,0,0,d->d1,d->fg,cFLAGS,d->d2);
11972 }
11973
11974 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, d->w, d->h);
11975 destroy_bitmap(buf);
11976 blit(bigbmp,screen,0,0,d->x-1,d->y-1,d->w,d->h);
11977 destroy_bitmap(bigbmp);
11978 }
11979
11980
11981 /*BITMAP *buf = create_bitmap_ex(8,16,16);
11982 if(buf)
11983 {
11984 clear_bitmap(buf);
11985 if(d->d1)
11986 putcombo(buf,0,0,d->d1,d->fg);
11987
11988 blit(buf,screen,0,0,d->x,d->y,d->w,d->h);
11989 destroy_bitmap(buf);
11990 }*/
11991 break;
11992 }
11993
11994 return D_O_K;
11995 }
11996
11997 /*int32_t d_scombo2_proc(int32_t msg, DIALOG *d, int32_t c)
11998 {
11999 //these are here to bypass compiler warnings about unused arguments
12000 c=c;
12001
12002 switch(msg)
12003 {
12004 case MSG_CLICK:
12005 if (CHECK_CTRL_CMD)
12006 {
12007 select_scombo(d->d1);
12008 }
12009 else
12010 {
12011 select_scombo(d->d1);
12012 }
12013 d_scombo_proc(MSG_DRAW,d,0);
12014 break;
12015
12016
12017 case MSG_DRAW:
12018 BITMAP *buf = create_bitmap_ex(8,16,16);
12019 if(buf)
12020 {
12021 clear_bitmap(buf);
12022 Map.draw_secret2(buf,d->d1);
12023 blit(buf,screen,0,0,d->x,d->y,16,16);
12024 destroy_bitmap(buf);
12025 }
12026 break;
12027 }
12028
12029 return D_O_K;
12030 }*/
12031
12032 int32_t onSecretF();
12033
12034 static int32_t secret_burn_list[] =
12035 {
12036 // dialog control number
12037 4, 5, 6, 7, 48, 49, 50, 51, 92, 93, 94, 95, -1
12038 };
12039
12040 static int32_t secret_arrow_list[] =
12041 {
12042 // dialog control number
12043 8, 9, 10, 52, 53, 54, 96, 97, 98, -1
12044 };
12045
12046 static int32_t secret_bomb_list[] =
12047 {
12048 // dialog control number
12049 11, 12, 55, 56, 99, 100, -1
12050 };
12051
12052 static int32_t secret_boomerang_list[] =
12053 {
12054 // dialog control number
12055 13, 14, 15, 57, 58, 59, 101, 102, 103, -1
12056 };
12057
12058 static int32_t secret_magic_list[] =
12059 {
12060 // dialog control number
12061 16, 17, 60, 61, 104, 105, -1
12062 };
12063
12064 static int32_t secret_sword_list[] =
12065 {
12066 // dialog control number
12067 18, 19, 20, 21, 22, 23, 24, 25, 62, 63, 64, 65, 66, 67, 68, 69, 106, 107, 108, 109, 110, 111, 112, 113, -1
12068 };
12069
12070 static int32_t secret_misc_list[] =
12071 {
12072 // dialog control number
12073 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, -1
12074 };
12075
12076 static TABPANEL secret_tabs[] =
12077 {
12078 // (text)
12079 { (char *)"Burn", D_SELECTED, secret_burn_list, 0, NULL },
12080 { (char *)"Arrow", 0, secret_arrow_list, 0, NULL },
12081 { (char *)"Bomb", 0, secret_bomb_list, 0, NULL },
12082 { (char *)"Boomerang", 0, secret_boomerang_list, 0, NULL },
12083 { (char *)"Magic", 0, secret_magic_list, 0, NULL },
12084 { (char *)"Sword", 0, secret_sword_list, 0, NULL },
12085 { (char *)"Misc", 0, secret_misc_list, 0, NULL },
12086 { NULL, 0, NULL, 0, NULL }
12087 };
12088
12089 static DIALOG secret_dlg[] =
12090 {
12091 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
12092 { jwin_win_proc, 0, 0, 301, 212, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12093 { jwin_tab_proc, 6, 25, 289, 156, 0, 0, 0, 0, 0, 0, (void *) secret_tabs, NULL, (void *)secret_dlg },
12094 { jwin_button_proc, 80, 187, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12095 { jwin_button_proc, 160, 187, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12096 // 4
12097 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Fire", NULL, NULL },
12098 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Strong Fire", NULL, NULL },
12099 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Fire", NULL, NULL },
12100 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Divine Fire", NULL, NULL },
12101 //8
12102 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Arrow", NULL, NULL },
12103 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Silver Arrow", NULL, NULL },
12104 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Golden Arrow", NULL, NULL },
12105 //11
12106 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Bomb", NULL, NULL },
12107 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Super Bomb", NULL, NULL },
12108 //13
12109 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Boomerang", NULL, NULL },
12110 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Boomerang", NULL, NULL },
12111 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Fire Boomerang", NULL, NULL },
12112 //16
12113 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand Magic", NULL, NULL },
12114 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Magic", NULL, NULL },
12115 //18
12116 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
12117 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword", NULL, NULL },
12118 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword", NULL, NULL },
12119 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword", NULL, NULL },
12120 { jwin_text_proc, 160, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword Beam", NULL, NULL },
12121 { jwin_text_proc, 160, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword Beam", NULL, NULL },
12122 { jwin_text_proc, 160, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword Beam", NULL, NULL },
12123 { jwin_text_proc, 160, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword Beam", NULL, NULL },
12124 //26
12125 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Stairs", NULL, NULL },
12126 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Fireball", NULL, NULL },
12127 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
12128 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand", NULL, NULL },
12129 { jwin_text_proc, 12, 141, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
12130 { jwin_text_proc, 12, 163, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Weapon", NULL, NULL },
12131 //32
12132 { jwin_ctext_proc, 235, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Flags 16-31", NULL, NULL },
12133 { jwin_text_proc, 87, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Secrets->Next (Flag only)", NULL, NULL },
12134 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 03", NULL, NULL },
12135 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 04", NULL, NULL },
12136 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 05", NULL, NULL },
12137 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 06", NULL, NULL },
12138 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 07", NULL, NULL },
12139 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 08", NULL, NULL },
12140 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 09", NULL, NULL },
12141 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 10", NULL, NULL },
12142 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 11", NULL, NULL },
12143 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 12", NULL, NULL },
12144 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 13", NULL, NULL },
12145 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 14", NULL, NULL },
12146 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 15", NULL, NULL },
12147 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 16", NULL, NULL },
12148 //48 (burn)
12149 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12150 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12151 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12152 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12153 //52 (arrow)
12154 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12155 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12156 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12157 //55 (bomb)
12158 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12159 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12160 //57 (boomerang)
12161 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12162 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12163 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12164 //60 (magic)
12165 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12166 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12167 //62 (sword)
12168 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12169 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12170 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12171 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12172 { jwin_frame_proc, 256, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12173 { jwin_frame_proc, 256, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12174 { jwin_frame_proc, 256, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12175 { jwin_frame_proc, 256, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12176 //70 (misc)
12177 { jwin_frame_proc, 63, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12178 { jwin_frame_proc, 63, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12179 { jwin_frame_proc, 63, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12180 { jwin_frame_proc, 63, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12181 { jwin_frame_proc, 63, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12182 { jwin_frame_proc, 63, 157, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12183 //76 (16-32)
12184 { jwin_frame_proc, 192, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12185 { jwin_frame_proc, 214, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12186 { jwin_frame_proc, 236, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12187 { jwin_frame_proc, 258, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12188 { jwin_frame_proc, 192, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12189 { jwin_frame_proc, 214, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12190 { jwin_frame_proc, 236, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12191 { jwin_frame_proc, 258, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12192 { jwin_frame_proc, 192, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12193 { jwin_frame_proc, 214, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12194 { jwin_frame_proc, 236, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12195 { jwin_frame_proc, 258, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12196 { jwin_frame_proc, 192, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12197 { jwin_frame_proc, 214, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12198 { jwin_frame_proc, 236, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12199 { jwin_frame_proc, 258, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12200
12201 //92 (burn)
12202 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12203 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12204 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12205 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12206 //96 (arrow)
12207 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12208 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12209 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12210 //99 (bomb)
12211 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12212 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12213 //101 (boomerang)
12214 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12215 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12216 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12217 //104 (magic)
12218 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12219 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12220 //106 (sword)
12221 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12222 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12223 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12224 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12225 { d_scombo_proc, 258, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12226 { d_scombo_proc, 258, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12227 { d_scombo_proc, 258, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12228 { d_scombo_proc, 258, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12229 //114 (misc)
12230 { d_scombo_proc, 65, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12231 { d_scombo_proc, 65, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12232 { d_scombo_proc, 65, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12233 { d_scombo_proc, 65, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12234 { d_scombo_proc, 65, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12235 { d_scombo_proc, 65, 159, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12236 //120 (16-32)
12237 { d_scombo_proc, 194, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12238 { d_scombo_proc, 216, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12239 { d_scombo_proc, 238, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12240 { d_scombo_proc, 260, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12241 { d_scombo_proc, 194, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12242 { d_scombo_proc, 216, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12243 { d_scombo_proc, 238, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12244 { d_scombo_proc, 260, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12245 { d_scombo_proc, 194, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12246 { d_scombo_proc, 216, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12247 { d_scombo_proc, 238, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12248 { d_scombo_proc, 260, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12249 { d_scombo_proc, 194, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12250 { d_scombo_proc, 216, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12251 { d_scombo_proc, 238, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12252 { d_scombo_proc, 260, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12253 //136 Secrets->Next
12254 { jwin_frame_proc, 158, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12255 { d_scombo_proc, 160, 49, 16, 16, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
12256 //138
12257 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12258 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'f', 0, 0, 0, (void *) onSecretF, NULL, NULL },
12259 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12260 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12261 };
12262
12263 int32_t onSecretF()
12264 {
12265 Flags^=cFLAGS;
12266 object_message(secret_dlg+1, MSG_DRAW, 0);
12267 return D_O_K;
12268 }
12269
12270
12271 int32_t onSecretCombo()
12272 {
12273 secret_dlg[0].dp2=get_zc_font(font_lfont);
12274
12275
12276 mapscr *s;
12277
12278 if(CurrentLayer==0)
12279 {
12280 s=Map.CurrScr();
12281 }
12282 else
12283 {
12284 // s=TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS+(Map.CurrScr()->layerscreen[CurrentLayer-1])];
12285 s=Map.AbsoluteScr((Map.CurrScr()->layermap[CurrentLayer-1]-1), (Map.CurrScr()->layerscreen[CurrentLayer-1]));
12286 }
12287 if(!s) return D_O_K;
12288
12289 char secretcombonumstr[27];
12290 sprintf(secretcombonumstr,"Secret Combos for Layer %d", CurrentLayer);
12291 secret_dlg[0].dp = secretcombonumstr;
12292
12293 secret_dlg[92].d1 = s->secretcombo[sBCANDLE];
12294 secret_dlg[92].fg = s->secretcset[sBCANDLE];
12295 secret_dlg[92].d2 = s->secretflag[sBCANDLE];
12296
12297 secret_dlg[93].d1 = s->secretcombo[sRCANDLE];
12298 secret_dlg[93].fg = s->secretcset[sRCANDLE];
12299 secret_dlg[93].d2 = s->secretflag[sRCANDLE];
12300
12301 secret_dlg[94].d1 = s->secretcombo[sWANDFIRE];
12302 secret_dlg[94].fg = s->secretcset[sWANDFIRE];
12303 secret_dlg[94].d2 = s->secretflag[sWANDFIRE];
12304
12305 secret_dlg[95].d1 = s->secretcombo[sDIVINEFIRE];
12306 secret_dlg[95].fg = s->secretcset[sDIVINEFIRE];
12307 secret_dlg[95].d2 = s->secretflag[sDIVINEFIRE];
12308
12309 secret_dlg[96].d1 = s->secretcombo[sARROW];
12310 secret_dlg[96].fg = s->secretcset[sARROW];
12311 secret_dlg[96].d2 = s->secretflag[sARROW];
12312
12313 secret_dlg[97].d1 = s->secretcombo[sSARROW];
12314 secret_dlg[97].fg = s->secretcset[sSARROW];
12315 secret_dlg[97].d2 = s->secretflag[sSARROW];
12316
12317 secret_dlg[98].d1 = s->secretcombo[sGARROW];
12318 secret_dlg[98].fg = s->secretcset[sGARROW];
12319 secret_dlg[98].d2 = s->secretflag[sGARROW];
12320
12321 secret_dlg[99].d1 = s->secretcombo[sBOMB];
12322 secret_dlg[99].fg = s->secretcset[sBOMB];
12323 secret_dlg[99].d2 = s->secretflag[sBOMB];
12324
12325 secret_dlg[100].d1 = s->secretcombo[sSBOMB];
12326 secret_dlg[100].fg = s->secretcset[sSBOMB];
12327 secret_dlg[100].d2 = s->secretflag[sSBOMB];
12328
12329 for(int32_t i=0; i<3; i++)
12330 {
12331 secret_dlg[101+i].d1 = s->secretcombo[sBRANG+i];
12332 secret_dlg[101+i].fg = s->secretcset[sBRANG+i];
12333 secret_dlg[101+i].d2 = s->secretflag[sBRANG+i];
12334 }
12335
12336 for(int32_t i=0; i<2; i++)
12337 {
12338 secret_dlg[104+i].d1 = s->secretcombo[sWANDMAGIC+i];
12339 secret_dlg[104+i].fg = s->secretcset[sWANDMAGIC+i];
12340 secret_dlg[104+i].d2 = s->secretflag[sWANDMAGIC+i];
12341 }
12342
12343 for(int32_t i=0; i<8; i++)
12344 {
12345 secret_dlg[106+i].d1 = s->secretcombo[sSWORD+i];
12346 secret_dlg[106+i].fg = s->secretcset[sSWORD+i];
12347 secret_dlg[106+i].d2 = s->secretflag[sSWORD+i];
12348 }
12349
12350 secret_dlg[114].d1 = s->secretcombo[sSTAIRS];
12351 secret_dlg[114].fg = s->secretcset[sSTAIRS];
12352 secret_dlg[114].d2 = s->secretflag[sSTAIRS];
12353
12354 secret_dlg[115].d1 = s->secretcombo[sREFFIREBALL];
12355 secret_dlg[115].fg = s->secretcset[sREFFIREBALL];
12356 secret_dlg[115].d2 = s->secretflag[sREFFIREBALL];
12357
12358 for(int32_t i=0; i<4; i++)
12359 {
12360 secret_dlg[116+i].d1 = s->secretcombo[sHOOKSHOT+i];
12361 secret_dlg[116+i].fg = s->secretcset[sHOOKSHOT+i];
12362 secret_dlg[116+i].d2 = s->secretflag[sHOOKSHOT+i];
12363 }
12364
12365 for(int32_t i=0; i<16; i++)
12366 {
12367 secret_dlg[120+i].d1 = s->secretcombo[sSECRET01+i];
12368 secret_dlg[120+i].fg = s->secretcset[sSECRET01+i];
12369 secret_dlg[120+i].d2 = s->secretflag[sSECRET01+i];
12370 }
12371
12372 //Sec->Next doesn't have a combo/cset value associated
12373 secret_dlg[137].d1 = 0;
12374 secret_dlg[137].fg = 0;
12375 secret_dlg[137].d2 = s->secretflag[sSECNEXT];
12376
12377 large_dialog(secret_dlg,1.75);
12378
12379 for(int32_t q = 0; secret_dlg[q].proc != NULL; ++q)
12380 {
12381 if(secret_dlg[q].proc == jwin_frame_proc)
12382 secret_dlg[q].w = secret_dlg[q].h = 36;
12383 }
12384
12385 go();
12386
12387 if(do_zqdialog(secret_dlg,3) == 2)
12388 {
12389 saved = false;
12390 s->secretcombo[sBCANDLE] = secret_dlg[92].d1;
12391 s->secretcset[sBCANDLE] = secret_dlg[92].fg;
12392 s->secretflag[sBCANDLE] = secret_dlg[92].d2;
12393
12394 s->secretcombo[sRCANDLE] = secret_dlg[93].d1;
12395 s->secretcset[sRCANDLE] = secret_dlg[93].fg;
12396 s->secretflag[sRCANDLE] = secret_dlg[93].d2;
12397
12398 s->secretcombo[sWANDFIRE] = secret_dlg[94].d1;
12399 s->secretcset[sWANDFIRE] = secret_dlg[94].fg;
12400 s->secretflag[sWANDFIRE] = secret_dlg[94].d2;
12401
12402 s->secretcombo[sDIVINEFIRE] = secret_dlg[95].d1;
12403 s->secretcset[sDIVINEFIRE] = secret_dlg[95].fg;
12404 s->secretflag[sDIVINEFIRE] = secret_dlg[95].d2;
12405
12406 s->secretcombo[sARROW] = secret_dlg[96].d1;
12407 s->secretcset[sARROW] = secret_dlg[96].fg;
12408 s->secretflag[sARROW] = secret_dlg[96].d2;
12409
12410 s->secretcombo[sSARROW] = secret_dlg[97].d1;
12411 s->secretcset[sSARROW] = secret_dlg[97].fg;
12412 s->secretflag[sSARROW] = secret_dlg[97].d2;
12413
12414 s->secretcombo[sGARROW] = secret_dlg[98].d1;
12415 s->secretcset[sGARROW] = secret_dlg[98].fg;
12416 s->secretflag[sGARROW] = secret_dlg[98].d2;
12417
12418 s->secretcombo[sBOMB] = secret_dlg[99].d1;
12419 s->secretcset[sBOMB] = secret_dlg[99].fg;
12420 s->secretflag[sBOMB] = secret_dlg[99].d2;
12421
12422 s->secretcombo[sSBOMB] = secret_dlg[100].d1;
12423 s->secretcset[sSBOMB] = secret_dlg[100].fg;
12424 s->secretflag[sSBOMB] = secret_dlg[100].d2;
12425
12426 for(int32_t i=0; i<3; i++)
12427 {
12428 s->secretcombo[sBRANG+i] = secret_dlg[101+i].d1;
12429 s->secretcset[sBRANG+i] = secret_dlg[101+i].fg;
12430 s->secretflag[sBRANG+i] = secret_dlg[101+i].d2;
12431 }
12432
12433 for(int32_t i=0; i<2; i++)
12434 {
12435 s->secretcombo[sWANDMAGIC+i] = secret_dlg[104+i].d1;
12436 s->secretcset[sWANDMAGIC+i] = secret_dlg[104+i].fg;
12437 s->secretflag[sWANDMAGIC+i] = secret_dlg[104+i].d2;
12438 }
12439
12440 for(int32_t i=0; i<8; i++)
12441 {
12442 s->secretcombo[sSWORD+i] = secret_dlg[106+i].d1;
12443 s->secretcset[sSWORD+i] = secret_dlg[106+i].fg;
12444 s->secretflag[sSWORD+i] = secret_dlg[106+i].d2;
12445 }
12446
12447 s->secretcombo[sSTAIRS] = secret_dlg[114].d1;
12448 s->secretcset[sSTAIRS] = secret_dlg[114].fg;
12449 s->secretflag[sSTAIRS] = secret_dlg[114].d2;
12450
12451 s->secretcombo[sREFFIREBALL] = secret_dlg[115].d1;
12452 s->secretcset[sREFFIREBALL] = secret_dlg[115].fg;
12453 s->secretflag[sREFFIREBALL] = secret_dlg[115].d2;
12454
12455 for(int32_t i=0; i<4; i++)
12456 {
12457 s->secretcombo[sHOOKSHOT+i] = secret_dlg[116+i].d1;
12458 s->secretcset[sHOOKSHOT+i] = secret_dlg[116+i].fg;
12459 s->secretflag[sHOOKSHOT+i] = secret_dlg[116+i].d2;
12460 }
12461
12462 for(int32_t i=0; i<16; i++)
12463 {
12464 s->secretcombo[sSECRET01+i] = secret_dlg[120+i].d1;
12465 s->secretcset[sSECRET01+i] = secret_dlg[120+i].fg;
12466 s->secretflag[sSECRET01+i] = secret_dlg[120+i].d2;
12467 }
12468 s->secretflag[sSECNEXT] = secret_dlg[137].d2;
12469
12470 }
12471
12472 comeback();
12473 return D_O_K;
12474 }
12475
12476 static DIALOG under_dlg[] =
12477 {
12478 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
12479 { jwin_win_proc, 72, 60, 176+1,120+1,vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12480 { jwin_text_proc, 115, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "Current", NULL, NULL },
12481 { d_comboframe_proc, 122, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12482 { d_combo_proc, 124, 94, 16, 16, 0, 0, 0, D_NOCLICK, 0, 0, NULL, NULL, NULL },
12483 { jwin_text_proc, 184, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "New", NULL, NULL },
12484 { d_comboframe_proc, 182, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12485 { d_combo_proc, 184, 94, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12486 { jwin_button_proc, 90, 124, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
12487 { jwin_button_proc, 170, 124, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
12488 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
12489 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12490 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12491 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12492 };
12493
12494 int32_t onUnderCombo()
12495 {
12496 char titlebuf[64];
12497 sprintf(titlebuf, "Under Combo (Layer %d)", CurrentLayer);
12498 under_dlg[0].dp = titlebuf;
12499 under_dlg[0].dp2 = get_zc_font(font_lfont);
12500 mapscr* scr;
12501 if(CurrentLayer==0)
12502 {
12503 scr=Map.CurrScr();
12504 }
12505 else
12506 {
12507 auto map=Map.CurrScr()->layermap[CurrentLayer-1]-1;
12508 auto screen=Map.CurrScr()->layerscreen[CurrentLayer-1];
12509 scr = Map.AbsoluteScr(map,screen);
12510 }
12511 if(!scr) return D_O_K;
12512
12513 under_dlg[3].d1=scr->undercombo;
12514 under_dlg[3].fg=scr->undercset;
12515
12516 under_dlg[6].d1=Combo;
12517 under_dlg[6].fg=CSet;
12518
12519 large_dialog(under_dlg);
12520 // Doesn't place "New" and "Current" text too well
12521 under_dlg[1].x=342;
12522 under_dlg[4].x=438;
12523
12524 int32_t ret = do_zqdialog(under_dlg,-1);
12525
12526 if(ret==7)
12527 {
12528 saved=false;
12529 scr->undercombo = under_dlg[6].d1;
12530 scr->undercset = under_dlg[6].fg;
12531 }
12532
12533 if(ret==9 && jwin_alert("Confirm Overwrite","Set all Under Combos","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
12534 {
12535 saved=false;
12536
12537 for(int32_t i=0; i<128; i++)
12538 {
12539 Map.Scr(i)->undercombo = under_dlg[6].d1;
12540 Map.Scr(i)->undercset = under_dlg[6].fg;
12541 }
12542 }
12543
12544 return D_O_K;
12545 }
12546
12547 static DIALOG list_dlg[] =
12548 {
12549 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12550 9 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12551 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12552 9 { jwin_list_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12553 9 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12554 9 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12555 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12556 };
12557
12558 static DIALOG wlist_dlg[] =
12559 {
12560 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12561 9 { jwin_win_proc, 60-12, 40, 200+24+24, 156, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12562 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12563 9 { d_wlist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12564 9 { jwin_button_proc, 90, 171, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
12565 9 { jwin_button_proc, 170, 171, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
12566 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12567 };
12568
12569
12570 /*
12571 typedef struct item_struct {
12572 char *s;
12573 int32_t i;
12574 } item_struct;
12575 */
12576 item_struct bii[MAXITEMS+1];
12577 int32_t bii_cnt=-1;
12578
12579 void build_bii_list(bool usenone)
12580 {
12581 int32_t start=bii_cnt=0;
12582
12583 if(usenone)
12584 {
12585 bii[0].s = (char *)"(None)";
12586 bii[0].i = -2;
12587 bii_cnt=start=1;
12588 }
12589
12590 for(int32_t i=0; i<MAXITEMS; i++)
12591 {
12592 bii[bii_cnt].s = item_string[i];
12593 bii[bii_cnt].i = i;
12594 ++bii_cnt;
12595 }
12596
12597 for(int32_t i=start; i<bii_cnt-1; i++)
12598 {
12599 for(int32_t j=i+1; j<bii_cnt; j++)
12600 {
12601 if(stricmp(bii[i].s,bii[j].s)>0 && strcmp(bii[j].s,""))
12602 {
12603 zc_swap(bii[i],bii[j]);
12604 }
12605 }
12606 }
12607 }
12608
12609
12610 const char *itemlist(int32_t index, int32_t *list_size)
12611 {
12612 if(index<0)
12613 {
12614 *list_size = bii_cnt;
12615 return NULL;
12616 }
12617
12618 return bii[index].s;
12619 }
12620 const char *itemlist_num(int32_t index, int32_t *list_size)
12621 {
12622 if(index<0)
12623 {
12624 *list_size = bii_cnt;
12625 return NULL;
12626 }
12627 static char biin_buf[64+6];
12628 if(bii[index].i < 0)
12629 return bii[index].s;
12630 sprintf(biin_buf, "%s (%03d)", bii[index].s, bii[index].i);
12631 return biin_buf;
12632 }
12633
12634 // disable items on dmaps stuff
12635 int32_t DI[MAXITEMS];
12636 int32_t nDI;
12637
12638 void initDI(int32_t index)
12639 {
12640 int32_t j=0;
12641
12642 for(int32_t i=0; i<MAXITEMS; i++)
12643 {
12644 int32_t index1=bii[i].i; // true index of item in dmap's DI list
12645
12646 if(DMaps[index].disableditems[index1])
12647 {
12648 DI[j]=i;
12649 j++;
12650 }
12651 }
12652
12653 nDI=j;
12654
12655 for(int32_t i=j; i<MAXITEMS; i++) DI[j]=0;
12656
12657 return;
12658 }
12659
12660 void insertDI(int32_t id, int32_t index)
12661 {
12662 int32_t trueid=bii[id].i;
12663 DMaps[index].disableditems[trueid] |= 1; //bit set
12664 initDI(index);
12665 return;
12666 }
12667
12668 void deleteDI(int32_t id, int32_t index)
12669 {
12670 int32_t i=DI[id];
12671 int32_t trueid=bii[i].i;
12672 DMaps[index].disableditems[trueid] &= (~1); // bit clear
12673 initDI(index);
12674 return;
12675 }
12676
12677 const char *DIlist(int32_t index, int32_t *list_size)
12678 {
12679 if(index<0)
12680 {
12681 *list_size = nDI;
12682 return NULL;
12683 }
12684
12685 int32_t i=DI[index];
12686 return bii[i].s;
12687
12688 }
12689
12690 weapon_struct biw[MAXWPNS];
12691 int32_t biw_cnt=-1;
12692
12693 void build_biw_list()
12694 {
12695 int32_t start=biw_cnt=0;
12696
12697 for(int32_t i=start; i<MAXWPNS; i++)
12698 {
12699 biw[biw_cnt].s = (char *)weapon_string[i];
12700 biw[biw_cnt].i = i;
12701 ++biw_cnt;
12702 }
12703
12704 for(int32_t i=start; i<biw_cnt-1; i++)
12705 {
12706 for(int32_t j=i+1; j<biw_cnt; j++)
12707 if(stricmp(biw[i].s,biw[j].s)>0 && strcmp(biw[j].s,""))
12708 zc_swap(biw[i],biw[j]);
12709 }
12710 }
12711
12712 const char *weaponlist(int32_t index, int32_t *list_size)
12713 {
12714 if(index<0)
12715 {
12716 *list_size = biw_cnt;
12717 return NULL;
12718 }
12719
12720 return biw[index].s;
12721 }
12722 const char *weaponlist_num(int32_t index, int32_t *list_size)
12723 {
12724 if(index<0)
12725 {
12726 *list_size = biw_cnt;
12727 return NULL;
12728 }
12729 static char biwn_buf[64+6];
12730 if(biw[index].i < 0)
12731 return biw[index].s;
12732 sprintf(biwn_buf, "%s (%03d)", biw[index].s, biw[index].i);
12733 return biwn_buf;
12734 }
12735 int32_t writeoneweapon(PACKFILE *f, int32_t index)
12736 {
12737 dword section_version=V_WEAPONS;
12738 dword section_cversion=CV_WEAPONS;
12739 int32_t zversion = ZELDA_VERSION;
12740 int32_t zbuild = VERSION_BUILD;
12741 int32_t iid = biw[index].i;
12742 al_trace("Writing Weapon Sprite .zwpnspr file for weapon id: %d\n", iid);
12743
12744 //section version info
12745 if(!p_iputl(zversion,f))
12746 {
12747 return 0;
12748 }
12749 if(!p_iputl(zbuild,f))
12750 {
12751 return 0;
12752 }
12753 if(!p_iputw(section_version,f))
12754 {
12755 return 0;
12756 }
12757
12758 if(!p_iputw(section_cversion,f))
12759 {
12760 return 0;
12761 }
12762
12763 //weapon string
12764
12765 if(!pfwrite((char *)weapon_string[iid], 64, f))
12766 {
12767 return 0;
12768 }
12769
12770 if(!p_putc(wpnsbuf[iid].misc,f))
12771 {
12772 return 0;
12773 }
12774
12775 if(!p_putc(wpnsbuf[iid].csets,f))
12776 {
12777 return 0;
12778 }
12779
12780 if(!p_putc(wpnsbuf[iid].frames,f))
12781 {
12782 return 0;
12783 }
12784
12785 if(!p_putc(wpnsbuf[iid].speed,f))
12786 {
12787 return 0;
12788 }
12789
12790 if(!p_putc(wpnsbuf[iid].type,f))
12791 {
12792 return 0;
12793 }
12794
12795 if(!p_iputw(wpnsbuf[iid].script,f))
12796 {
12797 return 0;
12798 }
12799
12800 //2.55 starts here
12801 if(!p_iputl(wpnsbuf[iid].tile,f))
12802 {
12803 return 0;
12804 }
12805
12806 return 1;
12807 }
12808
12809
12810 int32_t readoneweapon(PACKFILE *f, int32_t index)
12811 {
12812 dword section_version = 0;
12813 dword section_cversion = 0;
12814 int32_t zversion = 0;
12815 int32_t zbuild = 0;
12816 wpndata tempwpnspr;
12817 memset(&tempwpnspr, 0, sizeof(wpndata));
12818
12819
12820 //char dmapstring[64]={0};
12821 //section version info
12822 if(!p_igetl(&zversion,f))
12823 {
12824 return 0;
12825 }
12826 if(!p_igetl(&zbuild,f))
12827 {
12828 return 0;
12829 }
12830 if(!p_igetw(&section_version,f))
12831 {
12832 return 0;
12833 }
12834 if(!p_igetw(&section_cversion,f))
12835 {
12836 return 0;
12837 }
12838 al_trace("readoneweapon section_version: %d\n", section_version);
12839 al_trace("readoneweapon section_cversion: %d\n", section_cversion);
12840
12841 if ( zversion > ZELDA_VERSION )
12842 {
12843 al_trace("Cannot read .zwpnspr packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
12844 return 0;
12845 }
12846
12847 else if ( ( section_version > V_WEAPONS ) || ( section_version == V_WEAPONS && section_cversion < CV_WEAPONS ) )
12848 {
12849 al_trace("Cannot read .zwpnspr packfile made using V_WEAPONS (%d) subversion (%d)\n", section_version, section_cversion);
12850 return 0;
12851
12852 }
12853 else
12854 {
12855 al_trace("Reading a .zwpnspr packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
12856 }
12857
12858 char tmp_wpn_name[64];
12859 memset(tmp_wpn_name,0,64);
12860 if(!pfread(&tmp_wpn_name, 64, f))
12861 {
12862 return 0;
12863 }
12864
12865 word oldtile = 0;
12866 if(section_version < 8)
12867 if(!p_igetw(&oldtile,f))
12868 return 0;
12869
12870 if(!p_getc(&tempwpnspr.misc,f))
12871 {
12872 return 0;
12873 }
12874
12875 if(!p_getc(&tempwpnspr.csets,f))
12876 {
12877 return 0;
12878 }
12879
12880 if(!p_getc(&tempwpnspr.frames,f))
12881 {
12882 return 0;
12883 }
12884
12885 if(!p_getc(&tempwpnspr.speed,f))
12886 {
12887 return 0;
12888 }
12889
12890 if(!p_getc(&tempwpnspr.type,f))
12891 {
12892 return 0;
12893 }
12894
12895 if(!p_igetw(&tempwpnspr.script,f))
12896 {
12897 return 0;
12898 }
12899
12900 //2.55 starts here
12901 if ( zversion >= 0x255 )
12902 {
12903 if ( section_version >= 7 )
12904 {
12905 if(!p_igetl(&tempwpnspr.tile,f))
12906 {
12907 return 0;
12908 }
12909 }
12910 }
12911 if ( zversion < 0x255 )
12912 {
12913 tempwpnspr.tile = oldtile;
12914 }
12915 ::memcpy( &(wpnsbuf[biw[index].i]),&tempwpnspr, sizeof(wpndata));
12916 ::memcpy(weapon_string[biw[index].i], tmp_wpn_name, 64);
12917
12918 return 1;
12919 }
12920
12921
12922 static wpndata copiedSprite;
12923 static byte spritecopied = 0;
12924 char temp_weapon_string[64] = {0};
12925
12926 void paste_wsprite(int32_t index = -1)
12927 {
12928 if(index < 0) index = wlist_dlg[2].d1;
12929 if(unsigned(index)>255)
12930 return;
12931 if(!spritecopied)
12932 return;
12933 ::memcpy( &(wpnsbuf[biw[index].i]),&copiedSprite, sizeof(wpndata));
12934 ::memcpy(weapon_string[biw[index].i], temp_weapon_string, 64);
12935 wlist_dlg[2].flags|=D_DIRTY;
12936 saved=false;
12937 }
12938 void copy_wsprite(int32_t index = -1)
12939 {
12940 if(index < 0) index = wlist_dlg[2].d1;
12941 if(unsigned(index)>255)
12942 return;
12943 ::memcpy(&copiedSprite, &(wpnsbuf[biw[index].i]), sizeof(wpndata));
12944 memset(temp_weapon_string,0,64);
12945 ::memcpy(temp_weapon_string, weapon_string[biw[index].i], 64);
12946 spritecopied = 1;
12947 }
12948 void save_wsprite(int32_t index = -1)
12949 {
12950 if(index < 0) index = wlist_dlg[2].d1;
12951 if(unsigned(index)>255)
12952 return;
12953 if(!prompt_for_new_file_compat("Save ZWPNSPR(.zwpnspr)", "zwpnspr", NULL,datapath,false))
12954 return;
12955
12956 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
12957 if(!f) return;
12958 if (!writeoneweapon(f,index))
12959 {
12960 Z_error("Could not write to .zwpnspr packfile %s\n", temppath);
12961 InfoDialog("ZWpnSpr Error", "Could not save the specified sprite.").show();
12962 }
12963 pack_fclose(f);
12964 }
12965 void load_wsprite(int32_t index = -1)
12966 {
12967 if(index < 0) index = wlist_dlg[2].d1;
12968 if(unsigned(index)>255)
12969 return;
12970 if(!prompt_for_existing_file_compat("Load ZWPNSPR(.zwpnspr)", "zwpnspr", NULL,datapath,false))
12971 return;
12972 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
12973 if(!f) return;
12974
12975 if (!readoneweapon(f,index))
12976 {
12977 Z_error("Could not read from .zwpnspr packfile %s\n", temppath);
12978 InfoDialog("ZWpnSpr Error", "Could not load the specified sprite.").show();
12979 }
12980
12981 pack_fclose(f);
12982 wlist_dlg[2].flags|=D_DIRTY;
12983 saved=false;
12984 }
12985 void wpnsprite_rclick_func(int32_t index, int32_t x, int32_t y)
12986 {
12987 if(((unsigned)index)>255)
12988 return;
12989 NewMenu rcmenu {
12990 { "&Copy", [&](){copy_wsprite(index);} },
12991 { "Paste", "&v", [&](){paste_wsprite(index);}, 0, !spritecopied },
12992 { "&Save", [&](){save_wsprite(index);} },
12993 { "&Load", [&](){load_wsprite(index);} },
12994 };
12995 rcmenu.pop(x, y);
12996 }
12997
12998
12999 int32_t select_weapon(const char *prompt,int32_t weapon)
13000 {
13001 if(biw_cnt==-1)
13002 build_biw_list();
13003
13004 int32_t index=0;
13005
13006 for(int32_t j=0; j<biw_cnt; j++)
13007 {
13008 if(biw[j].i == weapon)
13009 {
13010 index=j;
13011 }
13012 }
13013
13014 wlist_dlg[0].dp=(void *)prompt;
13015 wlist_dlg[0].dp2=get_zc_font(font_lfont);
13016 wlist_dlg[2].d1=index;
13017 ListData weapon_list(weaponlist_num, &font);
13018 wlist_dlg[2].dp=(void *) &weapon_list;
13019 wlist_dlg[2].dp3 = (void *)&wpnsprite_rclick_func;
13020 wlist_dlg[2].flags|=(D_USER<<1);
13021
13022 large_dialog(wlist_dlg);
13023
13024 int32_t ret=do_zqdialog(wlist_dlg,2);
13025
13026 if(ret==0||ret==4)
13027 {
13028 position_mouse_z(0);
13029 return -1;
13030 }
13031
13032 index = wlist_dlg[2].d1;
13033 position_mouse_z(0);
13034 return biw[index].i;
13035 }
13036
13037 static int32_t seldata_copy;
13038 static void (*seldata_paste_func)(int32_t, int32_t);
13039
13040 void seldata_rclick_func(int32_t index, int32_t x, int32_t y)
13041 {
13042 NewMenu rcmenu {
13043 { "&Copy", [&](){seldata_copy = index;} },
13044 { "Paste", "&v", [&]()
13045 {
13046 seldata_paste_func(seldata_copy, index);
13047 saved = false;
13048 }, 0, seldata_copy < 0 },
13049 };
13050 rcmenu.pop(x, y);
13051 }
13052
13053 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), FONT *title_font, void (*copyFunc)(int32_t, int32_t))
13054 {
13055 if(proc==NULL)
13056 return -1;
13057
13058 list_dlg[0].dp=(void *)prompt;
13059 list_dlg[0].dp2=title_font;
13060 list_dlg[2].d1=index;
13061 ListData select_list(proc, &font);
13062 list_dlg[2].dp=(void *) &select_list;
13063
13064 large_dialog(list_dlg);
13065
13066 seldata_copy=-1;
13067 seldata_paste_func=copyFunc;
13068 if(copyFunc)
13069 {
13070 list_dlg[2].flags|=D_USER<<1;
13071 list_dlg[2].dp3=(void*)seldata_rclick_func;
13072 }
13073 else
13074 {
13075 list_dlg[2].flags&=~(D_USER<<1);
13076 list_dlg[2].dp3=0;
13077 }
13078
13079 int32_t ret=do_zqdialog(list_dlg,2);
13080
13081 if(ret==0||ret==4)
13082 {
13083 position_mouse_z(0);
13084 return -1;
13085 }
13086
13087 return list_dlg[2].d1;
13088 }
13089
13090 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), const char *b1, const char *b2, FONT *title_font, void (*copyFunc)(int32_t, int32_t))
13091 {
13092 if(proc==NULL)
13093 return -1;
13094
13095 list_dlg[0].dp=(void *)prompt;
13096 list_dlg[0].dp2=title_font;
13097 list_dlg[2].d1=index;
13098 ListData select_data_list(proc, &font);
13099 list_dlg[2].dp=(void *) &select_data_list;
13100 list_dlg[3].dp=(void *)b1;
13101 list_dlg[4].dp=(void *)b2;
13102
13103 large_dialog(list_dlg);
13104
13105 seldata_copy=-1;
13106 seldata_paste_func=copyFunc;
13107 if(copyFunc)
13108 {
13109 list_dlg[2].flags|=D_USER<<1;
13110 list_dlg[2].dp3=(void*)seldata_rclick_func;
13111 }
13112 else
13113 {
13114 list_dlg[2].flags&=~(D_USER<<1);
13115 list_dlg[2].dp3=0;
13116 }
13117
13118 int32_t ret = do_zqdialog(list_dlg,2);
13119 list_dlg[3].dp=(void *) "OK";
13120 list_dlg[4].dp=(void *) "Cancel";
13121
13122 if(ret==0||ret==4)
13123 {
13124 position_mouse_z(0);
13125 return -1;
13126 }
13127
13128 position_mouse_z(0);
13129 return list_dlg[2].d1;
13130 }
13131
13132 static char sfx_str_buf[42];
13133
13134 const char *sfxlist(int32_t index, int32_t *list_size)
13135 {
13136 if(index>=0)
13137 {
13138 bound(index,0,WAV_COUNT-1);
13139 sprintf(sfx_str_buf,"%d: %s",index, index ? sfx_string[index] : "(None)");
13140 return sfx_str_buf;
13141 }
13142
13143 *list_size=WAV_COUNT;
13144 return NULL;
13145 }
13146
13147 9 static ListData sfx_list(sfxlist, &font);
13148
13149 const char *screenscriptdroplist(int32_t index, int32_t *list_size)
13150 {
13151 if(index<0)
13152 {
13153 *list_size = biscreens_cnt;
13154 return NULL;
13155 }
13156
13157 return biscreens[index].first.c_str();
13158 }
13159
13160 //droplist like the dialog proc, naming scheme for this stuff is awful...
13161 9 static ListData screenscript_list(screenscriptdroplist, &a4fonts[font_pfont]);
13162
13163 int32_t onScreenScript()
13164 {
13165 call_screendata_dialog(7);
13166 return D_O_K;
13167 }
13168
13169 int32_t onScrData()
13170 {
13171 restore_mouse();
13172 call_screendata_dialog();
13173 return D_O_K;
13174 }
13175
13176 const char *roomslist(int32_t index, int32_t *list_size)
13177 {
13178 if(index>=0)
13179 {
13180 if(index>=MAXROOMTYPES)
13181 index=MAXROOMTYPES-1;
13182
13183 return roomtype_string[index];
13184 }
13185
13186 *list_size=MAXROOMTYPES;
13187 return NULL;
13188 }
13189
13190 static char number_str_buf[MIDI_TRACK_BUFFER_SIZE];
13191 int32_t number_list_size=1;
13192 bool number_list_zero=false;
13193
13194 const char *numberlist(int32_t index, int32_t *list_size)
13195 {
13196 if(index>=0)
13197 {
13198 bound(index,0,number_list_size-1);
13199 sprintf(number_str_buf,"%d",index+(number_list_zero?0:1));
13200 return number_str_buf;
13201 }
13202
13203 *list_size=number_list_size;
13204 return NULL;
13205 }
13206
13207 static char dmap_str_buf[37];
13208 int32_t dmap_list_size=MAXDMAPS;
13209 bool dmap_list_zero=true;
13210
13211 const char *dmaplist(int32_t index, int32_t *list_size)
13212 {
13213 if(index>=0)
13214 {
13215 bound(index,0,dmap_list_size-1);
13216 sprintf(dmap_str_buf,"%3d-%s",index+(dmap_list_zero?0:1), DMaps[index].name);
13217 return dmap_str_buf;
13218 }
13219
13220 *list_size=dmap_list_size;
13221 return NULL;
13222 }
13223
13224 char *hexnumlist(int32_t index, int32_t *list_size)
13225 {
13226 if(index>=0)
13227 {
13228 bound(index,0,number_list_size-1);
13229 sprintf(number_str_buf,"%X",index+(number_list_zero?0:1));
13230 return number_str_buf;
13231 }
13232
13233 *list_size=number_list_size;
13234 return NULL;
13235 }
13236
13237 const char *maplist(int32_t index, int32_t *list_size)
13238 {
13239 if(index>=0)
13240 {
13241 bound(index,0,MAXMAPS-1);
13242 sprintf(number_str_buf,"%d",index+1);
13243 return number_str_buf;
13244 }
13245
13246 *list_size=MAXMAPS;
13247 return NULL;
13248 }
13249
13250 const char *gotomaplist(int32_t index, int32_t *list_size)
13251 {
13252 if(index>=0)
13253 {
13254 bound(index,0,map_count-1);
13255 sprintf(number_str_buf,"%d",index+1);
13256 return number_str_buf;
13257 }
13258
13259 *list_size = map_count;
13260 return NULL;
13261 }
13262
13263 const char *midilist(int32_t index, int32_t *list_size)
13264 {
13265 if(index>=0)
13266
13267 {
13268 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13269 return midi_string[index];
13270 }
13271
13272 *list_size=MAXCUSTOMMIDIS_ZQ;
13273 return NULL;
13274 }
13275
13276 const char *custommidilist(int32_t index, int32_t *list_size)
13277 {
13278 if(index>=0)
13279 {
13280 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13281 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),customtunes[index].data?customtunes[index].title:"(Empty)");
13282 return number_str_buf;
13283 }
13284
13285 *list_size=number_list_size;
13286 return NULL;
13287 }
13288
13289 const char *enhancedmusiclist(int32_t index, int32_t *list_size)
13290 {
13291 index=index; //this is here to prevent unused parameter warnings
13292 list_size=list_size; //this is here to prevent unused parameter warnings
13293 /*if(index>=0)
13294 {
13295 bound(index,0,MAXMUSIC-1);
13296 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),enhancedMusic[index].filename[0]?enhancedMusic[index].title:"(Empty)" );
13297 return number_str_buf;
13298 }
13299 *list_size=number_list_size;*/
13300 return NULL;
13301 }
13302
13303
13304 const char *levelnumlist(int32_t index, int32_t *list_size)
13305 {
13306 if(index>=0)
13307 {
13308 bound(index,0,0xFFF);
13309 sprintf(number_str_buf,"%.3X - %s",index,palnames[index]);
13310 return number_str_buf;
13311 }
13312
13313 *list_size=MAXLEVELS;
13314 return NULL;
13315 }
13316
13317 static char shop_str_buf[40];
13318 int32_t shop_list_size=1;
13319
13320 const char *shoplist(int32_t index, int32_t *list_size)
13321 {
13322 if(index>=0)
13323 {
13324 bound(index,0,shop_list_size-1);
13325 sprintf(shop_str_buf,"%3d: %s",index,QMisc.shop[index].name);
13326 return shop_str_buf;
13327 }
13328
13329 *list_size=shop_list_size;
13330 return NULL;
13331 }
13332
13333 static char bottle_str_buf[40];
13334 int32_t bottle_list_size=1;
13335
13336 const char *bottlelist(int32_t index, int32_t *list_size)
13337 {
13338 if(index>=0)
13339 {
13340 bound(index,0,bottle_list_size-1);
13341 sprintf(bottle_str_buf,"%2d: %s",index+1,QMisc.bottle_types[index].name);
13342 return bottle_str_buf;
13343 }
13344
13345 *list_size=bottle_list_size;
13346 return NULL;
13347 }
13348
13349 static char bottleshop_str_buf[40];
13350 int32_t bottleshop_list_size=1;
13351
13352 const char *bottleshoplist(int32_t index, int32_t *list_size)
13353 {
13354 if(index>=0)
13355 {
13356 bound(index,0,bottleshop_list_size-1);
13357 sprintf(bottleshop_str_buf,"%3d: %s",index,QMisc.bottle_shop_types[index].name);
13358 return bottleshop_str_buf;
13359 }
13360
13361 *list_size=bottleshop_list_size;
13362 return NULL;
13363 }
13364
13365 static char info_str_buf[40];
13366 int32_t info_list_size=1;
13367
13368 const char *infolist(int32_t index, int32_t *list_size)
13369 {
13370 if(index>=0)
13371 {
13372 bound(index,0,info_list_size-1);
13373 sprintf(info_str_buf,"%3d: %s",index,QMisc.info[index].name);
13374 return info_str_buf;
13375 }
13376
13377 *list_size=info_list_size;
13378 return NULL;
13379 }
13380
13381 bool mapcount_will_affect_layers(word newmapcount)
13382 {
13383 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13384 {
13385 mapscr *layerchecker=&TheMaps[i];
13386
13387 for(int32_t j=0; j<6; j++)
13388 {
13389 if(layerchecker->layermap[j]>(newmapcount))
13390 {
13391 return true;
13392 }
13393 }
13394 }
13395 return false;
13396 }
13397
13398 void update_map_count(word newmapcount)
13399 {
13400 if(map_count == newmapcount) return;
13401 saved = false;
13402 setMapCount2(newmapcount);
13403 //Prevent the nine 'last mapscreen' buttons from pointing to invlid locations
13404 //if the user reduces the mapcount. -Z ( 23rd September, 2019 )
13405 for ( int32_t q = 0; q < 9; q++ )
13406 {
13407 map_page[q].map = ( map_page[q].map > newmapcount-1 ) ? newmapcount-1 : map_page[q].map;
13408 }
13409 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13410 {
13411 fix_layers(&TheMaps[i], false);
13412 }
13413
13414 refresh(rMAP+rSCRMAP+rMENU);
13415 }
13416
13417 int32_t onGotoMap()
13418 {
13419 int32_t ret = select_data("Goto Map",Map.getCurrMap(),gotomaplist,get_zc_font(font_lfont));
13420
13421 if(ret >= 0)
13422 {
13423 int32_t m=Map.getCurrMap();
13424 Map.setCurrMap(ret);
13425
13426 if(m!=Map.getCurrMap())
13427 {
13428 reset_relational_tile_grid();
13429 }
13430 }
13431
13432 refresh(rALL);
13433 return D_O_K;
13434 }
13435
13436 int32_t onFlags()
13437 {
13438 restore_mouse();
13439 int32_t ret=select_cflag("Select Combo Flag",Flag);
13440 position_mouse_z(0);
13441
13442 if(ret>=0)
13443 {
13444 Flag=ret;
13445 refresh(rMENU);
13446 doflags();
13447 }
13448
13449 return D_O_K;
13450 }
13451
13452 static DIALOG usedcombo_list_dlg[] =
13453 {
13454 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13455 9 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combos Used", NULL, NULL },
13456 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13457 9 { jwin_textbox_proc, 72-12, 60+4, 176+24+1, 92+4, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
13458 9 { jwin_button_proc, 130, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13459 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13460 };
13461
13462
13463
13464 int32_t onUsedCombos()
13465 {
13466 restore_mouse();
13467 usedcombo_list_dlg[0].dp2=get_zc_font(font_lfont);
13468
13469 int32_t usedcombos[7][300][2];
13470 char combolist_text[65536];
13471 char temptext[80];
13472
13473 int32_t drawmap=Map.getCurrMap();
13474 int32_t drawscr=Map.getCurrScr();
13475 int32_t counter[7];
13476
13477 for(int32_t layer=0; layer<7; ++layer)
13478 {
13479 counter[layer]=0;
13480
13481 if(layer==0)
13482 {
13483 drawmap=Map.getCurrMap();
13484 drawscr=Map.getCurrScr();
13485 }
13486 else
13487 {
13488 drawmap=Map.CurrScr()->layermap[layer-1]-1;
13489 drawscr=Map.CurrScr()->layerscreen[layer-1];
13490 }
13491 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
13492 if(!draw_mapscr) continue;
13493
13494 usedcombos[layer][0][0]=draw_mapscr->data[0];
13495 usedcombos[layer][0][1]=1;
13496 counter[layer]=1;
13497
13498 for(int32_t i=1; i<176; ++i)
13499 {
13500 bool used=false;
13501
13502 for(int32_t j=0; j<counter[layer]; ++j)
13503 {
13504 if(usedcombos[layer][j][0]==draw_mapscr->data[i])
13505 {
13506 ++usedcombos[layer][j][1];
13507 used=true;
13508 break;
13509 }
13510 }
13511
13512 if(!used)
13513 {
13514 usedcombos[layer][counter[layer]][0]=draw_mapscr->data[i];
13515 usedcombos[layer][counter[layer]][1]=1;
13516 ++counter[layer];
13517 }
13518 }
13519
13520 for(int32_t i=0; i<counter[layer]-1; i++)
13521 {
13522 for(int32_t j=i+1; j<counter[layer]; j++)
13523 {
13524 if(usedcombos[layer][i][0]>usedcombos[layer][j][0])
13525 {
13526 zc_swap(usedcombos[layer][i][0],usedcombos[layer][j][0]);
13527 zc_swap(usedcombos[layer][i][1],usedcombos[layer][j][1]);
13528 }
13529 }
13530 }
13531 }
13532
13533 sprintf(combolist_text, " ");
13534
13535 for(int32_t layer=0; layer<7; ++layer)
13536 {
13537 if(counter[layer]>0)
13538 {
13539 if(layer>0)
13540 {
13541 strcat(combolist_text, "\n");
13542 }
13543
13544 sprintf(temptext, "Combos on layer %d\n-----------------\n", layer);
13545 strcat(combolist_text, temptext);
13546
13547 for(int32_t i=0; i<counter[layer]; i++)
13548 {
13549 if((i<counter[layer]-1) && (((usedcombos[layer][i][1]==usedcombos[layer][i+1][1]&&(usedcombos[layer][i][0]+1==usedcombos[layer][i+1][0])) && ((i==0) || ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))))
13550 {
13551 sprintf(temptext, "%5d ", usedcombos[layer][i][0]);
13552 strcat(combolist_text, temptext);
13553 }
13554 else if(((i>0) && (((usedcombos[layer][i][1]==usedcombos[layer][i-1][1])&&((usedcombos[layer][i][0]-1==usedcombos[layer][i-1][0]))) && ((i==counter[layer]-1) || ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0])))))))
13555 {
13556 sprintf(temptext, "- %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13557 strcat(combolist_text, temptext);
13558 }
13559 else if(((i==0) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))))||
13560 ((i==counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0]))))||
13561 ((i>0) && (i<counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))
13562 {
13563 sprintf(temptext, " %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13564 strcat(combolist_text, temptext);
13565 }
13566 }
13567 }
13568 }
13569
13570 strcat(combolist_text, "\n");
13571 usedcombo_list_dlg[2].dp=combolist_text;
13572 usedcombo_list_dlg[2].d2=0;
13573
13574 large_dialog(usedcombo_list_dlg);
13575
13576 do_zqdialog(usedcombo_list_dlg,2);
13577 position_mouse_z(0);
13578 return D_O_K;
13579 }
13580
13581 int32_t onItem()
13582 {
13583 restore_mouse();
13584 int32_t exit_status;
13585 int32_t current_item=Map.CurrScr()->hasitem != 0 ? Map.CurrScr()->item : -1;
13586
13587 ItemListerDialog(current_item,true).show();
13588 if(current_item != lister_sel_val)
13589 {
13590 if(lister_sel_val>=0)
13591 {
13592 saved = false;
13593 Map.CurrScr()->item = lister_sel_val;
13594 Map.CurrScr()->hasitem = true;
13595 }
13596 else
13597 {
13598 saved = false;
13599 Map.CurrScr()->hasitem = false;
13600 }
13601 }
13602
13603 refresh(rMAP+rMENU);
13604 return D_O_K;
13605 }
13606
13607 void call_room_dlg(mapscr* scr);
13608 int32_t onRoom()
13609 {
13610 restore_mouse();
13611 auto* scr = Map.CurrScr();
13612 call_room_dlg(scr);
13613
13614 refresh(rMAP+rMENU);
13615 return D_O_K;
13616 }
13617
13618 int32_t onEndString()
13619 {
13620 int32_t ret=select_data("Select Ending String",QMisc.endstring,msgslist,get_zc_font(font_lfont));
13621
13622 if(ret>=0)
13623 {
13624 saved=false;
13625 QMisc.endstring=msglistcache[ret];
13626 }
13627
13628 refresh(rMENU);
13629 return D_O_K;
13630 }
13631
13632 9 static ListData levelnum_list(levelnumlist, &font);
13633
13634 static DIALOG screen_pal_dlg[] =
13635 {
13636 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13637 9 { jwin_win_proc, 60-12, 40, 200-16, 96, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Palette", NULL, NULL },
13638 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13639 9 { jwin_droplist_proc, 72-12, 84+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &levelnum_list, NULL, NULL },
13640 9 { jwin_button_proc, 70, 111, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13641 9 { jwin_button_proc, 150, 111, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13642 9 { jwin_text_proc, 72-12, 60+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Note: This does not affect how the", NULL, NULL },
13643 9 { jwin_text_proc, 72-12, 72+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "room will be displayed in-game!", NULL, NULL },
13644 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13645 };
13646 // return list_dlg[2].d1;
13647
13648 int32_t onScreenPalette()
13649 {
13650 restore_mouse();
13651 screen_pal_dlg[0].dp2=get_zc_font(font_lfont);
13652 auto oldcol = screen_pal_dlg[2].d1 = Map.getcolor();
13653
13654 large_dialog(screen_pal_dlg);
13655 auto old_valid = Map.CurrScr()->valid;
13656 pause_dlg_tint(true);
13657 zq_set_screen_never_freeze(true);
13658 while(true)
13659 {
13660 auto ret = do_zqdialog(screen_pal_dlg,2);
13661 if(ret == 2)
13662 {
13663 Map.setcolor(screen_pal_dlg[2].d1);
13664 refresh(rALL);
13665 }
13666 else
13667 {
13668 if(ret == 3)
13669 {
13670 if(screen_pal_dlg[2].d1 != oldcol)
13671 saved=false;
13672 Map.setcolor(screen_pal_dlg[2].d1);
13673 }
13674 else
13675 {
13676 Map.setcolor(oldcol);
13677 Map.CurrScr()->valid = old_valid;
13678 }
13679 refresh(rALL);
13680 break;
13681 }
13682 }
13683 pause_dlg_tint(false);
13684 zq_set_screen_never_freeze(false);
13685
13686 rebuild_trans_table();
13687
13688 return D_O_K;
13689 }
13690
13691 int32_t onDecScrPal()
13692 {
13693 if(DisableLPalShortcuts)
13694 {
13695 lpal_dsa();
13696 return D_O_K;
13697 }
13698 restore_mouse();
13699 int32_t c=Map.getcolor();
13700 c+=511;
13701 c=c%512;
13702 Map.setcolor(c);
13703 refresh(rALL);
13704 saved = false;
13705 return D_O_K;
13706 }
13707
13708 int32_t onIncScrPal()
13709 {
13710 if(DisableLPalShortcuts)
13711 {
13712 lpal_dsa();
13713 return D_O_K;
13714 }
13715 restore_mouse();
13716 int32_t c=Map.getcolor();
13717 c+=1;
13718 c=c%512;
13719 Map.setcolor(c);
13720 refresh(rALL);
13721 saved = false;
13722 return D_O_K;
13723 }
13724
13725 int32_t PalWrap(int32_t kX, int32_t const kLowerBound, int32_t const kUpperBound)
13726 {
13727 int32_t range_size = kUpperBound - kLowerBound + 1;
13728
13729 if (kX < kLowerBound)
13730 kX += range_size * ((kLowerBound - kX) / range_size + 1);
13731
13732 return kLowerBound + (kX - kLowerBound) % range_size;
13733 }
13734
13735 int32_t onDecScrPal16()
13736 {
13737 if(DisableLPalShortcuts)
13738 {
13739 lpal_dsa();
13740 return D_O_K;
13741 }
13742 restore_mouse();
13743 int32_t c=Map.getcolor();
13744
13745 c = PalWrap( ( c-0x10 ), 0, 511 );
13746
13747 Map.setcolor(c);
13748 refresh(rALL);
13749 saved = false;
13750 return D_O_K;
13751 }
13752
13753 int32_t onIncScrPal16()
13754 {
13755 if(DisableLPalShortcuts)
13756 {
13757 lpal_dsa();
13758 return D_O_K;
13759 }
13760 restore_mouse();
13761 int32_t c=Map.getcolor();
13762
13763 c = PalWrap( ( c+0x10 ), 0, 511 );
13764 Map.setcolor(c);
13765 refresh(rALL);
13766 saved = false;
13767 return D_O_K;
13768 }
13769
13770 int32_t d_ndroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13771 {
13772 int32_t ret = jwin_droplist_proc(msg,d,c);
13773
13774 // The only place this proc is used is in the info type editor.
13775 // If it's ever used anywhere else, this will probably need to be changed.
13776 // Maybe add a flag for it or something.
13777 int32_t msgID=msg_at_pos(d->d1);
13778
13779 switch(msg)
13780 {
13781 case MSG_DRAW:
13782 case MSG_CHAR:
13783 case MSG_CLICK:
13784 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",msgID);
13785 }
13786
13787 return ret;
13788 }
13789
13790 int32_t d_idroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13791 {
13792 int32_t ret = jwin_droplist_proc(msg,d,c);
13793
13794 switch(msg)
13795 {
13796 case MSG_DRAW:
13797 case MSG_CHAR:
13798 case MSG_CLICK:
13799 int32_t tile = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].tile : 0;
13800 int32_t cset = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].csets&15 : 0;
13801 int32_t x = d->x + d->w + 4;
13802 int32_t y = d->y - 8;
13803 int32_t w = 32;
13804 int32_t h = 32;
13805
13806 BITMAP *buf = create_bitmap_ex(8,16,16);
13807 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13808
13809 if(buf && bigbmp)
13810 {
13811 clear_bitmap(buf);
13812
13813 if(tile)
13814 overtile16(buf, tile,0,0,cset,0);
13815
13816 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13817 destroy_bitmap(buf);
13818 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13819 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13820 destroy_bitmap(bigbmp);
13821 }
13822
13823 }
13824
13825 return ret;
13826 }
13827
13828 int32_t d_nidroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13829 {
13830 int32_t ret = d_idroplist_proc(msg,d,c);
13831
13832 switch(msg)
13833 {
13834 case MSG_DRAW:
13835 case MSG_CHAR:
13836 case MSG_CLICK:
13837 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",bii[d->d1].i);
13838 }
13839
13840 return ret;
13841 }
13842
13843 int32_t d_wlist_proc(int32_t msg,DIALOG *d,int32_t c)
13844 {
13845 if(msg == MSG_XCHAR)
13846 {
13847 if(key_shifts & KB_CTRL_FLAG) //CTRL overrides the lister search function
13848 {
13849 int32_t ret = D_USED_CHAR;
13850 switch(c>>8)
13851 {
13852 case KEY_V:
13853 paste_wsprite();
13854 break;
13855 case KEY_C:
13856 copy_wsprite();
13857 break;
13858 case KEY_S:
13859 save_wsprite();
13860 break;
13861 case KEY_L:
13862 load_wsprite();
13863 break;
13864 default: ret = 0;
13865 }
13866 if(ret) return ret;
13867 }
13868 }
13869 int32_t ret = jwin_abclist_proc(msg,d,c);
13870
13871 switch(msg)
13872 {
13873 case MSG_DRAW:
13874 case MSG_CHAR:
13875 case MSG_CLICK:
13876
13877 int32_t tile = 0;
13878 int32_t cset = 0;
13879 tile= wpnsbuf[biw[d->d1].i].tile;
13880 cset= wpnsbuf[biw[d->d1].i].csets&15;
13881 int32_t x = d->x + d->w + 4;
13882 int32_t y = d->y;
13883 int32_t w = 32;
13884 int32_t h = 32;
13885 float temp_scale = 2;
13886
13887 BITMAP *buf = create_bitmap_ex(8,16,16);
13888 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13889
13890 if(buf && bigbmp)
13891 {
13892 clear_bitmap(buf);
13893
13894 if(tile)
13895 overtile16(buf, tile,0,0,cset,0);
13896
13897 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13898 destroy_bitmap(buf);
13899 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13900 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13901 destroy_bitmap(bigbmp);
13902 }
13903
13904 //Display the sprite ID.
13905 if (biw[d->d1].i >= 0)
13906 {
13907 textprintf_ex(screen, font, x, y + (20 * temp_scale), jwin_pal[jcTEXTFG], jwin_pal[jcBOX], "#%d ", biw[d->d1].i);
13908 }
13909
13910 }
13911
13912 return ret;
13913 }
13914
13915 // Triforce pieces
13916 static byte triframe_points[9*4] =
13917 {
13918 0,2,2,0, 2,0,4,2, 0,2,4,2, 1,1,3,1, 2,0,2,2,
13919 1,1,1,2, 1,1,2,2, 3,1,3,2, 3,1,2,2
13920 };
13921
13922 int32_t d_tri_frame_proc(int32_t msg,DIALOG *d,int32_t c)
13923 {
13924 //these are here to bypass compiler warnings about unused arguments
13925 c=c;
13926
13927 if(msg==MSG_DRAW)
13928 {
13929 int32_t x[5],y[3];
13930
13931 x[0]=d->x;
13932 x[1]=d->x+(d->w>>2);
13933 x[2]=d->x+(d->w>>1);
13934 x[3]=d->x+(d->w>>1)+(d->w>>2);
13935 x[4]=d->x+d->w;
13936 y[0]=d->y;
13937 y[1]=d->y+(d->h>>1);
13938 y[2]=d->y+d->h;
13939
13940 byte *p = triframe_points;
13941
13942 for(int32_t i=0; i<9; i++)
13943 {
13944 line(screen,x[*p],y[*(p+1)],x[*(p+2)],y[*(p+3)],d->fg);
13945 p+=4;
13946 }
13947 }
13948
13949 return D_O_K;
13950 }
13951
13952 int32_t d_tri_edit_proc(int32_t msg,DIALOG *d,int32_t c)
13953 {
13954 jwin_button_proc(msg,d,c);
13955
13956 if(msg==MSG_CLICK)
13957 {
13958 int32_t v = getnumber("Piece Number",d->d1);
13959
13960 if(v>=0)
13961 {
13962 bound(v,1,8);
13963
13964 if(v!=d->d1)
13965 {
13966 DIALOG *tp = d - d->d2;
13967
13968 for(int32_t i=0; i<8; i++)
13969 {
13970 if(tp->d1==v)
13971 {
13972 tp->d1 = d->d1;
13973 ((char*)(tp->dp))[0] = d->d1+'0';
13974 jwin_button_proc(MSG_DRAW,tp,0);
13975 }
13976
13977 ++tp;
13978 }
13979
13980 d->d1 = v;
13981 ((char*)(d->dp))[0] = v+'0';
13982 }
13983 }
13984
13985 d->flags = 0;
13986 jwin_button_proc(MSG_DRAW,d,0);
13987 }
13988
13989 return D_O_K;
13990 }
13991
13992 static DIALOG tp_dlg[] =
13993 {
13994 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13995 9 { jwin_win_proc, 56, 32, 208, 160, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
13996 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13997 9 { d_tri_frame_proc, 64, 56, 192, 96, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, NULL, NULL, NULL },
13998 // 3
13999 9 { d_tri_edit_proc, 138, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
14000 9 { d_tri_edit_proc, 166, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 1, (void *) "2", NULL, NULL },
14001 9 { d_tri_edit_proc, 90, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 2, (void *) "3", NULL, NULL },
14002 9 { d_tri_edit_proc, 214, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 3, (void *) "4", NULL, NULL },
14003 // 7
14004 9 { d_tri_edit_proc, 138, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 4, (void *) "5", NULL, NULL },
14005 9 { d_tri_edit_proc, 118, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 5, (void *) "6", NULL, NULL },
14006 9 { d_tri_edit_proc, 166, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 6, (void *) "7", NULL, NULL },
14007 9 { d_tri_edit_proc, 186, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 7, (void *) "8", NULL, NULL },
14008 // 11
14009 9 { jwin_button_proc, 90, 166, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
14010 9 { jwin_button_proc, 170, 166, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14011 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14012 };
14013
14014 int32_t onTriPieces()
14015 {
14016 tp_dlg[0].dp2=get_zc_font(font_lfont);
14017 char temptext[8][2];
14018
14019 for(int32_t i=0; i<8; i++)
14020 {
14021 tp_dlg[i+3].d1 = QMisc.triforce[i];
14022 // ((char*)(tp_dlg[i+3].dp))[0] = QMisc.triforce[i]+'0';
14023 sprintf(temptext[i], "%d", QMisc.triforce[i]);
14024 tp_dlg[i+3].dp=temptext[i];
14025 }
14026
14027 large_dialog(tp_dlg);
14028
14029 if(do_zqdialog(tp_dlg,-1) == 11)
14030 {
14031 saved=false;
14032
14033 for(int32_t i=0; i<8; i++)
14034 QMisc.triforce[i] = tp_dlg[i+3].d1;
14035 }
14036
14037 return D_O_K;
14038 }
14039
14040 int32_t d_maptile_proc(int32_t msg,DIALOG *d,int32_t c);
14041 bool small_dmap=false;
14042
14043 static DIALOG dmapmaps_dlg[] =
14044 {
14045
14046 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14047 { jwin_win_proc, 4, 18, 313, 217, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Custom DMap Map Styles", NULL, NULL },
14048 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14049 { jwin_button_proc, 93, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
14050 { jwin_button_proc, 168, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
14051 { d_ctext2_proc, 160, 38, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimaps", NULL, NULL },
14052 { d_ctext2_proc, 112, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
14053 { d_ctext2_proc, 208, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
14054
14055 { d_ctext2_proc, 162, 110, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Large Maps", NULL, NULL },
14056 { d_ctext2_proc, 80, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
14057 { d_ctext2_proc, 240, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
14058 // 5
14059 { d_maptile_proc, 72, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14060 { d_maptile_proc, 168, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14061 { d_maptile_proc, 8, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14062 { d_maptile_proc, 168, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14063 // 11
14064 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14065 };
14066
14067 int32_t d_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
14068 {
14069 return jwin_hexedit_proc(msg,d,c);
14070 }
14071
14072 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
14073 {
14074 if(div!=-1)
14075 rectfill(dest,x-1,y-1,x+63,y+3,div);
14076
14077 for(int32_t dx=0; dx<64; dx+=8)
14078 {
14079 if(grid&0x80)
14080 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
14081 else if(bg!=-1)
14082 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14083
14084 grid<<=1;
14085 }
14086 }
14087
14088 void drawovergrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t color,int32_t div)
14089 {
14090 if(div!=-1)
14091 rectfill(dest,x-1,y-1,x+63,y+3,div);
14092
14093 for(int32_t dx=0; dx<64; dx+=4)
14094 {
14095 rectfill(dest,x+dx,y,x+dx+2,y+2,color);
14096 grid<<=1;
14097 }
14098 }
14099
14100 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t w, int32_t h, int32_t tw, int32_t th, int32_t *grid,int32_t fg,int32_t bg,int32_t div)
14101 {
14102 //these are here to bypass compiler warnings about unused arguments
14103 w=w;
14104 tw=tw;
14105 th=th;
14106
14107 rectfill(dest,x,y,x+(8*8),y+(1*4),div);
14108
14109 for(int32_t dy=0; dy<h; dy++)
14110 {
14111 for(int32_t dx=0; dx<64; dx+=8)
14112 {
14113 if(grid[0]&0x80)
14114 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
14115 else
14116 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14117
14118 grid[0]<<=1;
14119 }
14120 }
14121 }
14122
14123 void drawgrid_s(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
14124 {
14125 rectfill(dest,x-1,y-1,x+63,y+3,div);
14126
14127 for(int32_t dx=0; dx<64; dx+=8)
14128 {
14129 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
14130
14131 if(grid&0x80)
14132 rectfill(dest,x+dx+2,y,x+dx+4,y+2,fg);
14133
14134 grid<<=1;
14135 }
14136 }
14137
14138 void drawdmap(int32_t dmap)
14139 {
14140 int32_t c;
14141 zcolors mc=QMisc.colors;
14142
14143 switch((DMaps[dmap].type&dmfTYPE))
14144 {
14145 case dmDNGN:
14146 case dmCAVE:
14147 clear_bitmap(dmapbmp_small);
14148
14149 if(DMaps[dmap].minimap_2_tile)
14150 ;
14151 // overworld_map_tile overrides the NES minimap. dungeon_map_tile does not.
14152 else for(int32_t y=1; y<33; y+=4)
14153 drawgrid(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2], DMaps[dmap].flags&dmfMINIMAPCOLORFIX ? mc.cave_fg : mc.dngn_fg, -1, -1);
14154
14155 c=DMaps[dmap].compass;
14156 // rectfill(dmapbmp,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,dvc(2*4));
14157 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(4));
14158 c=DMaps[dmap].cont;
14159 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
14160 break;
14161
14162 case dmOVERW:
14163 clear_bitmap(dmapbmp_small);
14164
14165 if(DMaps[dmap].minimap_2_tile)
14166 ;
14167 else if(!mc.overworld_map_tile)
14168 for(int32_t y=1; y<33; y+=4)
14169 drawovergrid(dmapbmp_small,1,y,DMaps[dmap].grid[y>>2],mc.overw_bg,vc(0));
14170
14171 c=DMaps[dmap].cont;
14172 rectfill(dmapbmp_small,(c&15)*4+1,(c>>4)*4+1,(c&15)*4+3,(c>>4)*4+3,vc(10));
14173 break;
14174
14175 case dmBSOVERW:
14176 clear_bitmap(dmapbmp_small);
14177
14178 if(DMaps[dmap].minimap_2_tile)
14179 ;
14180 else if(!mc.overworld_map_tile)
14181 for(int32_t y=1; y<33; y+=4)
14182 // drawgrid_s(dmapbmp,1,y,DMaps[dmap].grid[y>>2],dvc(2*4),dvc(2*3),dvc(3+4));
14183 drawgrid_s(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2],mc.bs_goal,mc.bs_dk,vc(14));
14184
14185 c=DMaps[dmap].cont;
14186 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
14187 break;
14188 }
14189 }
14190
14191 void drawdmap_screen(int32_t x, int32_t y, int32_t w, int32_t h, int32_t dmap)
14192 {
14193 BITMAP *tempbmp = create_bitmap_ex(8,w,h);
14194 clear_to_color(tempbmp, vc(0));
14195 zcolors mc=QMisc.colors;
14196
14197 // rectfill(tempbmp,x,y,x+w-1,y+h-1,vc(0));
14198
14199 if(DMaps[dmap].minimap_2_tile)
14200 {
14201 draw_block(tempbmp,0,0,DMaps[dmap].minimap_2_tile,DMaps[dmap].minimap_2_cset,5,3);
14202 }
14203 else if(((DMaps[dmap].type&dmfTYPE)==dmDNGN || (DMaps[dmap].type&dmfTYPE)==dmCAVE) && mc.dungeon_map_tile)
14204 {
14205 draw_block(tempbmp,0,0,mc.dungeon_map_tile,mc.dungeon_map_cset,5,3);
14206 }
14207 else if(((DMaps[dmap].type&dmfTYPE)==dmOVERW || (DMaps[dmap].type&dmfTYPE)==dmBSOVERW) && mc.overworld_map_tile)
14208 {
14209 draw_block(tempbmp,0,0,mc.overworld_map_tile,mc.overworld_map_cset,5,3);
14210 }
14211
14212 masked_blit(dmapbmp_small,tempbmp,0,0,8,7,65,33);
14213
14214 blit(tempbmp,screen,0,0,x,y,w,h);
14215 destroy_bitmap(tempbmp);
14216
14217 }
14218
14219 int32_t d_dmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
14220 {
14221 if(msg==MSG_DRAW)
14222 {
14223 int32_t dmap = d->d1;
14224 int32_t xy[6] = {44,92,128,100,128,110};
14225 //int32_t *xy = (int32_t*)(d->dp3);
14226 float temp_scale = 1.5;
14227
14228 drawdmap(dmap);
14229
14230 if(xy[0]>-1000&&xy[1]>-1000)
14231 {
14232 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
14233 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
14234 int32_t w = 84;
14235 int32_t h = 52;
14236 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
14237 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
14238 }
14239
14240 if(xy[2]>-1000&&xy[3]>-1000)
14241 {
14242 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
14243 }
14244
14245 if(xy[4]>-1000&&xy[5]>-1000)
14246 {
14247 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
14248 }
14249 }
14250
14251 return jwin_list_proc(msg,d,c);
14252 }
14253
14254 int32_t d_dropdmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
14255 {
14256 if(msg==MSG_DRAW)
14257 {
14258 int32_t dmap = d->d1;
14259 int32_t *xy = (int32_t*)(d->dp3);
14260 float temp_scale = 1.5;
14261
14262 drawdmap(dmap);
14263
14264 if(xy[0]>-1000&&xy[1]>-1000)
14265 {
14266 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
14267 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
14268 int32_t w = 84;
14269 int32_t h = 52;
14270 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
14271 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
14272 }
14273
14274 if(xy[2]>-1000&&xy[3]>-1000)
14275 {
14276 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
14277 }
14278
14279 if(xy[4]>-1000&&xy[5]>-1000)
14280 {
14281 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
14282 }
14283 }
14284
14285 return jwin_droplist_proc(msg,d,c);
14286 }
14287
14288 void drawxmap(ALLEGRO_BITMAP* dest, int32_t themap, int32_t xoff, bool large, int dx, int dy)
14289 {
14290 ALLEGRO_STATE old_state;
14291 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
14292
14293 al_set_target_bitmap(dest);
14294 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
14295
14296 int32_t cols = (large ? 8 : 16);
14297 int32_t col_width = large ? 22 : 11;
14298 int32_t dot_width = (large ? 6 : 4);
14299 int32_t dot_offset = (large ? 7 : 3);
14300 int32_t l = 10;
14301
14302 for (int32_t y = 0; y < 8; y++)
14303 {
14304 // Users might have set the dmap to a map that has since been deleted.
14305 if (themap >= Map.getMapCount())
14306 break;
14307
14308 for (int32_t x = 0; x < cols; x++)
14309 {
14310 if (x + xoff < 0 || x + xoff > 15)
14311 continue;
14312 mapscr* scr = &TheMaps[themap * MAPSCRS + y * 16 + x + (large ? xoff : 0)];
14313 if (!(scr->valid & mVALID))
14314 continue;
14315 al_draw_filled_rectangle(dx + (x * col_width), dy + (y * l), dx + (x * col_width + col_width), dy + ((y * l) + l), real_lc1(scr->color));
14316
14317 al_draw_filled_rectangle(dx + (x * col_width + dot_offset), dy + (y * l + 3), dx + (x * col_width + dot_offset + dot_width), dy + (y * l + l - 3), real_lc2(scr->color));
14318 }
14319 }
14320
14321 al_restore_state(&old_state);
14322 }
14323
14324 const char *dmapscriptdroplist(int32_t index, int32_t *list_size)
14325 {
14326 if(index<0)
14327 {
14328 *list_size = bidmaps_cnt;
14329 return NULL;
14330 }
14331
14332 return bidmaps[index].first.c_str();
14333 }
14334
14335
14336 //droplist like the dialog proc, naming scheme for this stuff is awful...
14337 9 static ListData dmapscript_list(dmapscriptdroplist, &a4fonts[font_pfont]);
14338
14339 //int32_t selectdmapxy[6] = {90,142,164,150,164,160};
14340 int32_t selectdmapxy[6] = {44,92,128,100,128,110};
14341
14342 9 static ListData dmap_list(dmaplist, &font);
14343
14344 static DIALOG selectdmap_dlg[] =
14345 {
14346 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
14347 9 { jwin_win_proc, 72-44, 56-30, 176+88+1, 120+74+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select DMap", NULL, NULL },
14348 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
14349 9 { d_dmaplist_proc, 46, 50, 64+72+88+1, 60+24+1+2, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &dmap_list, NULL, selectdmapxy },
14350 9 { jwin_button_proc, 90, 152+44, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
14351 9 { jwin_button_proc, 170, 152+44, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
14352 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
14353 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_C, (void*)close_dlg, NULL, NULL },
14354 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_V, (void*)close_dlg, NULL, NULL },
14355 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
14356 };
14357
14358 9 static dmap copiedDMap;
14359 static byte dmapcopied = 0;
14360
14361 int32_t writesomedmaps(PACKFILE *f, int32_t first, int32_t last, int32_t max)
14362 {
14363
14364 dword section_version=V_DMAPS;
14365 dword section_cversion=CV_DMAPS;
14366 int32_t zversion = ZELDA_VERSION;
14367 int32_t zbuild = VERSION_BUILD;
14368
14369 if(!p_iputl(V_ZDMAP,f))
14370 {
14371 return 0;
14372 }
14373
14374 //section version info
14375 if(!p_iputl(zversion,f))
14376 {
14377 return 0;
14378 }
14379 if(!p_iputl(zbuild,f))
14380 {
14381 return 0;
14382 }
14383 if(!p_iputw(section_version,f))
14384 {
14385 new_return(2);
14386 }
14387
14388 if(!p_iputw(section_cversion,f))
14389 {
14390 new_return(3);
14391 }
14392 //max possible at this time
14393 if(!p_iputl(max,f))
14394 {
14395 new_return(4);
14396 }
14397 //first id written
14398 if(!p_iputl(first,f))
14399 {
14400 new_return(5);
14401 }
14402 //last id written
14403 if(!p_iputl(last,f))
14404 {
14405 new_return(6);
14406 }
14407 int32_t count = last-first;
14408 //number written
14409 if(!p_iputl(count,f))
14410 {
14411 new_return(7);
14412 }
14413
14414
14415 for ( int32_t i = first; i <= last; ++i )
14416 {
14417 if ( i > max ) break;
14418
14419 if(!p_putc(DMaps[i].map,f))
14420 {
14421 new_return(8);
14422 }
14423
14424 if(!p_iputw(DMaps[i].level,f))
14425 {
14426 new_return(9);
14427 }
14428
14429 if(!p_putc(DMaps[i].xoff,f))
14430 {
14431 new_return(10);
14432 }
14433
14434 if(!p_putc(DMaps[i].compass,f))
14435 {
14436 new_return(11);
14437 }
14438
14439 if(!p_iputw(DMaps[i].color,f))
14440 {
14441 new_return(12);
14442 }
14443
14444 if(!p_putc(DMaps[i].midi,f))
14445 {
14446 new_return(13);
14447 }
14448
14449 if(!p_putc(DMaps[i].cont,f))
14450 {
14451 new_return(14);
14452 }
14453
14454 if(!p_putc(DMaps[i].type,f))
14455 {
14456 new_return(15);
14457 }
14458
14459 for(int32_t j=0; j<8; j++)
14460 {
14461 if(!p_putc(DMaps[i].grid[j],f))
14462 {
14463 new_return(16);
14464 }
14465 }
14466
14467 //16
14468 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14469 {
14470 new_return(17);
14471 }
14472
14473 if(!p_putwstr(DMaps[i].title,f))
14474 {
14475 new_return(18);
14476 }
14477
14478 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14479 {
14480 new_return(19);
14481 }
14482
14483 if(!p_iputl(DMaps[i].minimap_1_tile,f))
14484 {
14485 new_return(20);
14486 }
14487
14488 if(!p_putc(DMaps[i].minimap_1_cset,f))
14489 {
14490 new_return(21);
14491 }
14492
14493 if(!p_iputl(DMaps[i].minimap_2_tile,f))
14494 {
14495 new_return(22);
14496 }
14497
14498 if(!p_putc(DMaps[i].minimap_2_cset,f))
14499 {
14500 new_return(23);
14501 }
14502
14503 if(!p_iputl(DMaps[i].largemap_1_tile,f))
14504 {
14505 new_return(24);
14506 }
14507
14508 if(!p_putc(DMaps[i].largemap_1_cset,f))
14509 {
14510 new_return(25);
14511 }
14512
14513 if(!p_iputl(DMaps[i].largemap_2_tile,f))
14514 {
14515 new_return(26);
14516 }
14517
14518 if(!p_putc(DMaps[i].largemap_2_cset,f))
14519 {
14520 new_return(27);
14521 }
14522
14523 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14524 {
14525 new_return(28);
14526 }
14527
14528 if(!p_putc(DMaps[i].tmusictrack,f))
14529 {
14530 new_return(29);
14531 }
14532
14533 if(!p_putc(DMaps[i].active_subscreen,f))
14534 {
14535 new_return(30);
14536 }
14537
14538 if(!p_putc(DMaps[i].passive_subscreen,f))
14539 {
14540 new_return(31);
14541 }
14542
14543 byte disabled[32];
14544 memset(disabled,0,32);
14545
14546 for(int32_t j=0; j<MAXITEMS; j++)
14547 {
14548 if(DMaps[i].disableditems[j])
14549 {
14550 disabled[j/8] |= (1 << (j%8));
14551 }
14552 }
14553
14554 if(!pfwrite(disabled,32,f))
14555 {
14556 new_return(32);
14557 }
14558
14559 if(!p_iputl(DMaps[i].flags,f))
14560 {
14561 new_return(33);
14562 }
14563 if(!p_putc(DMaps[i].sideview,f))
14564 {
14565 new_return(30);
14566 }
14567 if(!p_iputw(DMaps[i].script,f))
14568 {
14569 new_return(31);
14570 }
14571 for ( int32_t q = 0; q < 8; q++ )
14572 {
14573 if(!p_iputl(DMaps[i].initD[q],f))
14574 {
14575 new_return(32);
14576 }
14577
14578 }
14579 for ( int32_t q = 0; q < 8; q++ )
14580 {
14581 for ( int32_t w = 0; w < 65; w++ )
14582 {
14583 if (!p_putc(DMaps[i].initD_label[q][w],f))
14584 {
14585 new_return(33);
14586 }
14587 }
14588 }
14589 if(!p_iputw(DMaps[i].active_sub_script,f))
14590 {
14591 new_return(34);
14592 }
14593 if(!p_iputw(DMaps[i].passive_sub_script,f))
14594 {
14595 new_return(35);
14596 }
14597 for(int32_t q = 0; q < 8; ++q)
14598 {
14599 if(!p_iputl(DMaps[i].sub_initD[q],f))
14600 {
14601 new_return(36);
14602 }
14603 }
14604 for(int32_t q = 0; q < 8; ++q)
14605 {
14606 for(int32_t w = 0; w < 65; ++w)
14607 {
14608 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14609 {
14610 new_return(37);
14611 }
14612 }
14613 }
14614 if(!p_iputw(DMaps[i].onmap_script,f))
14615 {
14616 new_return(35);
14617 }
14618 for(int32_t q = 0; q < 8; ++q)
14619 {
14620 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14621 {
14622 new_return(36);
14623 }
14624 }
14625 for(int32_t q = 0; q < 8; ++q)
14626 {
14627 for(int32_t w = 0; w < 65; ++w)
14628 {
14629 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14630 {
14631 new_return(37);
14632 }
14633 }
14634 }
14635 if (!p_iputw(DMaps[i].mirrorDMap, f))
14636 {
14637 new_return(38);
14638 }
14639 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14640 {
14641 new_return(39);
14642 }
14643 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14644 {
14645 new_return(40);
14646 }
14647 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14648 {
14649 new_return(41);
14650 }
14651 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14652 {
14653 new_return(42);
14654 }
14655 }
14656
14657 return 1;
14658 }
14659
14660
14661 int32_t readsomedmaps(PACKFILE *f)
14662 {
14663 dword section_version = 0;
14664 dword section_cversion = 0;
14665 int32_t zversion = 0;
14666 int32_t zbuild = 0;
14667 dmap tempdmap{};
14668
14669 int32_t first = 0, last = 0, max = 0, count = 0;
14670 int32_t datatype_version = 0;
14671
14672 //char dmapstring[64]={0};
14673 //section version info
14674 if(!p_igetl(&datatype_version,f))
14675 {
14676 return 0;
14677 }
14678 if ( datatype_version < 0 )
14679 {
14680 if(!p_igetl(&zversion,f))
14681 {
14682 return 0;
14683 }
14684 }
14685 else
14686 {
14687 zversion = datatype_version;
14688 }
14689 if(!p_igetl(&zbuild,f))
14690 {
14691 return 0;
14692 }
14693
14694 if(!p_igetw(&section_version,f))
14695 {
14696 return 0;
14697 }
14698
14699 if(!p_igetw(&section_cversion,f))
14700 {
14701 return 0;
14702 }
14703 if ( datatype_version < 0 )
14704 {
14705 if(!p_igetl(&max,f))
14706 {
14707 return 0;
14708 }
14709 if(!p_igetl(&first,f))
14710 {
14711 return 0;
14712 }
14713 if(!p_igetl(&last,f))
14714 {
14715 return 0;
14716 }
14717 if(!p_igetl(&count,f))
14718 {
14719 return 0;
14720 }
14721 }
14722 else
14723 {
14724 first = 0;
14725 last = 0;
14726 count = 1;
14727 max = 255;
14728 }
14729
14730
14731
14732
14733 al_trace("readsomedmaps section_version: %d\n", section_version);
14734 al_trace("readsomedmaps section_cversion: %d\n", section_cversion);
14735
14736 if ( zversion > ZELDA_VERSION )
14737 {
14738 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
14739 return 0;
14740 }
14741 else if (( section_version > V_DMAPS ) || ( section_version == V_DMAPS && section_cversion > CV_DMAPS ) )
14742 {
14743 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d) subversion (%d)\n", section_version, section_cversion);
14744 return 0;
14745 }
14746 else
14747 {
14748 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
14749 }
14750 //if(!pfread(&dmapstring, 64, f))
14751 //{
14752 // return 0;
14753 //}
14754
14755
14756
14757 for ( int32_t i = first; i <= last; ++i )
14758 {
14759 if(!p_getc(&tempdmap.map,f))
14760 {
14761 return 0;
14762 }
14763
14764 if(!p_igetw(&tempdmap.level,f))
14765 {
14766 return 0;
14767 }
14768
14769 if(!p_getc(&tempdmap.xoff,f))
14770 {
14771 return 0;
14772 }
14773
14774 if(!p_getc(&tempdmap.compass,f))
14775 {
14776 return 0;
14777 }
14778
14779 if(!p_igetw(&tempdmap.color,f))
14780 {
14781 return 0;
14782 }
14783
14784 if(!p_getc(&tempdmap.midi,f))
14785 {
14786 return 0;
14787 }
14788
14789 if(!p_getc(&tempdmap.cont,f))
14790 {
14791 return 0;
14792 }
14793
14794 if(!p_getc(&tempdmap.type,f))
14795 {
14796 return 0;
14797 }
14798
14799 for(int32_t j=0; j<8; j++)
14800 {
14801 if(!p_getc(&tempdmap.grid[j],f))
14802 {
14803 return 0;
14804 }
14805 }
14806
14807 //16
14808 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
14809 {
14810 return 0;
14811 }
14812
14813 if (section_version<20)
14814 {
14815 char title[22];
14816 if (!p_getstr(title, sizeof(title) - 1, f))
14817 {
14818 return 0;
14819 }
14820 tempdmap.title.assign(title);
14821 }
14822 else
14823 {
14824 if (!p_getwstr(&tempdmap.title, f))
14825 {
14826 return 0;
14827 }
14828 }
14829
14830 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
14831 {
14832 return 0;
14833 }
14834
14835 if(!p_igetl(&tempdmap.minimap_1_tile,f))
14836 {
14837 return 0;
14838 }
14839
14840 if(!p_getc(&tempdmap.minimap_1_cset,f))
14841 {
14842 return 0;
14843 }
14844
14845 if(!p_igetl(&tempdmap.minimap_2_tile,f))
14846 {
14847 return 0;
14848 }
14849
14850 if(!p_getc(&tempdmap.minimap_2_cset,f))
14851 {
14852 return 0;
14853 }
14854
14855 if(!p_igetl(&tempdmap.largemap_1_tile,f))
14856 {
14857 return 0;
14858 }
14859
14860 if(!p_getc(&tempdmap.largemap_1_cset,f))
14861 {
14862 return 0;
14863 }
14864
14865 if(!p_igetl(&tempdmap.largemap_2_tile,f))
14866 {
14867 return 0;
14868 }
14869
14870 if(!p_getc(&tempdmap.largemap_2_cset,f))
14871 {
14872 return 0;
14873 }
14874
14875 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
14876 {
14877 return 0;
14878 }
14879
14880 if(!p_getc(&tempdmap.tmusictrack,f))
14881 {
14882 return 0;
14883 }
14884
14885 if(!p_getc(&tempdmap.active_subscreen,f))
14886 {
14887 return 0;
14888 }
14889
14890 if(!p_getc(&tempdmap.passive_subscreen,f))
14891 {
14892 return 0;
14893 }
14894
14895 byte disabled[32];
14896 memset(disabled,0,32);
14897
14898 if(!pfread(&disabled, 32, f)) return 0;
14899
14900 for(int32_t j=0; j<MAXITEMS; j++)
14901 {
14902 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
14903 else tempdmap.disableditems[j]=0;
14904 }
14905
14906
14907 if(!p_igetl(&tempdmap.flags,f))
14908 {
14909 return 0;
14910 }
14911 if ( zversion >= 0x255 )
14912 {
14913 if ( section_version >= 14 )
14914 {
14915 //2.55 starts here
14916 if(!p_getc(&tempdmap.sideview,f))
14917 {
14918 return 0;
14919 }
14920 if(!p_igetw(&tempdmap.script,f))
14921 {
14922 return 0;
14923 }
14924 for ( int32_t q = 0; q < 8; q++ )
14925 {
14926 if(!p_igetl(&tempdmap.initD[q],f))
14927 {
14928 return 0;
14929 }
14930
14931 }
14932 for ( int32_t q = 0; q < 8; q++ )
14933 {
14934 for ( int32_t w = 0; w < 65; w++ )
14935 {
14936 if (!p_getc(&tempdmap.initD_label[q][w],f))
14937 {
14938 return 0;
14939 }
14940 }
14941 }
14942 if(!p_igetw(&tempdmap.active_sub_script,f))
14943 {
14944 return 0;
14945 }
14946 if(!p_igetw(&tempdmap.passive_sub_script,f))
14947 {
14948 return 0;
14949 }
14950 for(int32_t q = 0; q < 8; ++q)
14951 {
14952 if(!p_igetl(&tempdmap.sub_initD[q],f))
14953 {
14954 return 0;
14955 }
14956 }
14957 for(int32_t q = 0; q < 8; ++q)
14958 {
14959 for(int32_t w = 0; w < 65; ++w)
14960 {
14961 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
14962 {
14963 return 0;
14964 }
14965 }
14966 }
14967 if(!p_igetw(&tempdmap.onmap_script,f))
14968 {
14969 return 0;
14970 }
14971 for(int32_t q = 0; q < 8; ++q)
14972 {
14973 if(!p_igetl(&tempdmap.onmap_initD[q],f))
14974 {
14975 return 0;
14976 }
14977 }
14978 for(int32_t q = 0; q < 8; ++q)
14979 {
14980 for(int32_t w = 0; w < 65; ++w)
14981 {
14982 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
14983 {
14984 return 0;
14985 }
14986 }
14987 }
14988 if (!p_igetw(&tempdmap.mirrorDMap, f))
14989 {
14990 return 0;
14991 }
14992 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
14993 {
14994 return 0;
14995 }
14996 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
14997 {
14998 return 0;
14999 }
15000 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15001 {
15002 return 0;
15003 }
15004 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15005 {
15006 return 0;
15007 }
15008 }
15009 }
15010 DMaps[i].clear();
15011 DMaps[i] = tempdmap;
15012 }
15013
15014 return 1;
15015 }
15016
15017
15018
15019 int32_t writeonedmap(PACKFILE *f, int32_t i)
15020 {
15021
15022 dword section_version=V_DMAPS;
15023 dword section_cversion=CV_DMAPS;
15024 int32_t zversion = ZELDA_VERSION;
15025 int32_t zbuild = VERSION_BUILD;
15026
15027
15028 //section version info
15029 if(!p_iputl(V_ZDMAP,f))
15030 {
15031 return 0;
15032 }
15033 if(!p_iputl(zversion,f))
15034 {
15035 return 0;
15036 }
15037 if(!p_iputl(zbuild,f))
15038 {
15039 return 0;
15040 }
15041 if(!p_iputw(section_version,f))
15042 {
15043 new_return(2);
15044 }
15045
15046 if(!p_iputw(section_cversion,f))
15047 {
15048 new_return(3);
15049 }
15050
15051
15052
15053 if(!p_putc(DMaps[i].map,f))
15054 {
15055 new_return(6);
15056 }
15057
15058 if(!p_iputw(DMaps[i].level,f))
15059 {
15060 new_return(7);
15061 }
15062
15063 if(!p_putc(DMaps[i].xoff,f))
15064 {
15065 new_return(8);
15066 }
15067
15068 if(!p_putc(DMaps[i].compass,f))
15069 {
15070 new_return(9);
15071 }
15072
15073 if(!p_iputw(DMaps[i].color,f))
15074 {
15075 new_return(10);
15076 }
15077
15078 if(!p_putc(DMaps[i].midi,f))
15079 {
15080 new_return(11);
15081 }
15082
15083 if(!p_putc(DMaps[i].cont,f))
15084 {
15085 new_return(12);
15086 }
15087
15088 if(!p_putc(DMaps[i].type,f))
15089 {
15090 new_return(13);
15091 }
15092
15093 for(int32_t j=0; j<8; j++)
15094 {
15095 if(!p_putc(DMaps[i].grid[j],f))
15096 {
15097 new_return(14);
15098 }
15099 }
15100
15101 //16
15102 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
15103 {
15104 new_return(15);
15105 }
15106
15107 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
15108 {
15109 new_return(16);
15110 }
15111
15112 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
15113 {
15114 new_return(17);
15115 }
15116
15117 if(!p_iputl(DMaps[i].minimap_1_tile,f))
15118 {
15119 new_return(18);
15120 }
15121
15122 if(!p_putc(DMaps[i].minimap_1_cset,f))
15123 {
15124 new_return(19);
15125 }
15126
15127 if(!p_iputl(DMaps[i].minimap_2_tile,f))
15128 {
15129 new_return(20);
15130 }
15131
15132 if(!p_putc(DMaps[i].minimap_2_cset,f))
15133 {
15134 new_return(21);
15135 }
15136
15137 if(!p_iputl(DMaps[i].largemap_1_tile,f))
15138 {
15139 new_return(22);
15140 }
15141
15142 if(!p_putc(DMaps[i].largemap_1_cset,f))
15143 {
15144 new_return(23);
15145 }
15146
15147 if(!p_iputl(DMaps[i].largemap_2_tile,f))
15148 {
15149 new_return(24);
15150 }
15151
15152 if(!p_putc(DMaps[i].largemap_2_cset,f))
15153 {
15154 new_return(25);
15155 }
15156
15157 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
15158 {
15159 new_return(26);
15160 }
15161
15162 if(!p_putc(DMaps[i].tmusictrack,f))
15163 {
15164 new_return(25);
15165 }
15166
15167 if(!p_putc(DMaps[i].active_subscreen,f))
15168 {
15169 new_return(26);
15170 }
15171
15172 if(!p_putc(DMaps[i].passive_subscreen,f))
15173 {
15174 new_return(27);
15175 }
15176
15177 byte disabled[32];
15178 memset(disabled,0,32);
15179
15180 for(int32_t j=0; j<MAXITEMS; j++)
15181 {
15182 if(DMaps[i].disableditems[j])
15183 {
15184 disabled[j/8] |= (1 << (j%8));
15185 }
15186 }
15187
15188 if(!pfwrite(disabled,32,f))
15189 {
15190 new_return(28);
15191 }
15192
15193 if(!p_iputl(DMaps[i].flags,f))
15194 {
15195 new_return(29);
15196 }
15197 if(!p_putc(DMaps[i].sideview,f))
15198 {
15199 new_return(30);
15200 }
15201 if(!p_iputw(DMaps[i].script,f))
15202 {
15203 new_return(31);
15204 }
15205 for ( int32_t q = 0; q < 8; q++ )
15206 {
15207 if(!p_iputl(DMaps[i].initD[q],f))
15208 {
15209 new_return(32);
15210 }
15211
15212 }
15213 for ( int32_t q = 0; q < 8; q++ )
15214 {
15215 for ( int32_t w = 0; w < 65; w++ )
15216 {
15217 if (!p_putc(DMaps[i].initD_label[q][w],f))
15218 {
15219 new_return(33);
15220 }
15221 }
15222 }
15223 if(!p_iputw(DMaps[i].active_sub_script,f))
15224 {
15225 new_return(34);
15226 }
15227 if(!p_iputw(DMaps[i].passive_sub_script,f))
15228 {
15229 new_return(35);
15230 }
15231 for(int32_t q = 0; q < 8; ++q)
15232 {
15233 if(!p_iputl(DMaps[i].sub_initD[q],f))
15234 {
15235 new_return(36);
15236 }
15237 }
15238 for(int32_t q = 0; q < 8; ++q)
15239 {
15240 for(int32_t w = 0; w < 65; ++w)
15241 {
15242 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
15243 {
15244 new_return(37);
15245 }
15246 }
15247 }
15248 if(!p_iputw(DMaps[i].onmap_script,f))
15249 {
15250 new_return(35);
15251 }
15252 for(int32_t q = 0; q < 8; ++q)
15253 {
15254 if(!p_iputl(DMaps[i].onmap_initD[q],f))
15255 {
15256 new_return(36);
15257 }
15258 }
15259 for(int32_t q = 0; q < 8; ++q)
15260 {
15261 for(int32_t w = 0; w < 65; ++w)
15262 {
15263 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
15264 {
15265 new_return(37);
15266 }
15267 }
15268 }
15269 if (!p_iputw(DMaps[i].mirrorDMap, f))
15270 {
15271 new_return(38);
15272 }
15273 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
15274 {
15275 new_return(39);
15276 }
15277 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
15278 {
15279 new_return(40);
15280 }
15281 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
15282 {
15283 new_return(41);
15284 }
15285 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
15286 {
15287 new_return(42);
15288 }
15289
15290 return 1;
15291 }
15292
15293
15294 int32_t readonedmap(PACKFILE *f, int32_t index)
15295 {
15296 dword section_version = 0;
15297 dword section_cversion = 0;
15298 int32_t zversion = 0;
15299 int32_t zbuild = 0;
15300 dmap tempdmap{};
15301 int32_t datatype_version = 0;
15302 int32_t first = 0;
15303 int32_t last = 0;
15304 int32_t max = 0;
15305 int32_t count = 0;
15306
15307 //char dmapstring[64]={0};
15308 //section version info
15309 if(!p_igetl(&datatype_version,f))
15310 {
15311 return 0;
15312 }
15313 if ( datatype_version < 0 )
15314 {
15315 if(!p_igetl(&zversion,f))
15316 {
15317 return 0;
15318 }
15319 }
15320 else
15321 {
15322 zversion = datatype_version;
15323 }
15324 if(!p_igetl(&zbuild,f))
15325 {
15326 return 0;
15327 }
15328
15329 if(!p_igetw(&section_version,f))
15330 {
15331 return 0;
15332 }
15333
15334 if(!p_igetw(&section_cversion,f))
15335 {
15336 return 0;
15337 }
15338 al_trace("readonedmap section_version: %d\n", section_version);
15339 al_trace("readonedmap section_cversion: %d\n", section_cversion);
15340
15341
15342 if ( datatype_version < 0 )
15343 {
15344 if(!p_igetl(&max,f))
15345 {
15346 return 0;
15347 }
15348 if(!p_igetl(&first,f))
15349 {
15350 return 0;
15351 }
15352 if(!p_igetl(&last,f))
15353 {
15354 return 0;
15355 }
15356 if(!p_igetl(&count,f))
15357 {
15358 return 0;
15359 }
15360 }
15361 if ( zversion > ZELDA_VERSION )
15362 {
15363 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
15364 return 0;
15365 }
15366 else if (( section_version > V_DMAPS ) || ( section_version == V_DMAPS && section_cversion > CV_DMAPS ) )
15367 {
15368 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d) subversion (%d)\n", section_version, section_cversion);
15369 return 0;
15370 }
15371 else
15372 {
15373 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
15374 }
15375 //if(!pfread(&dmapstring, 64, f))
15376 //{
15377 // return 0;
15378 //}
15379
15380
15381
15382
15383 if(!p_getc(&tempdmap.map,f))
15384 {
15385 return 0;
15386 }
15387
15388 if(!p_igetw(&tempdmap.level,f))
15389 {
15390 return 0;
15391 }
15392
15393 if(!p_getc(&tempdmap.xoff,f))
15394 {
15395 return 0;
15396 }
15397
15398 if(!p_getc(&tempdmap.compass,f))
15399 {
15400 return 0;
15401 }
15402
15403 if(!p_igetw(&tempdmap.color,f))
15404 {
15405 return 0;
15406 }
15407
15408 if(!p_getc(&tempdmap.midi,f))
15409 {
15410 return 0;
15411 }
15412
15413 if(!p_getc(&tempdmap.cont,f))
15414 {
15415 return 0;
15416 }
15417
15418 if(!p_getc(&tempdmap.type,f))
15419 {
15420 return 0;
15421 }
15422
15423 for(int32_t j=0; j<8; j++)
15424 {
15425 if(!p_getc(&tempdmap.grid[j],f))
15426 {
15427 return 0;
15428 }
15429 }
15430
15431 //16
15432 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
15433 {
15434 return 0;
15435 }
15436
15437 if (section_version<20)
15438 {
15439 char title[22];
15440 if (!p_getstr(title, sizeof(title) - 1, f))
15441 {
15442 return 0;
15443 }
15444 tempdmap.title.assign(title);
15445 }
15446 else
15447 {
15448 if (!p_getwstr(&tempdmap.title, f))
15449 {
15450 return 0;
15451 }
15452 }
15453
15454 if(!pfread(&tempdmap.title,sizeof(DMaps[0].title),f))
15455 {
15456 return 0;
15457 }
15458
15459 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
15460 {
15461 return 0;
15462 }
15463
15464 if(!p_igetl(&tempdmap.minimap_1_tile,f))
15465 {
15466 return 0;
15467 }
15468
15469 if(!p_getc(&tempdmap.minimap_1_cset,f))
15470 {
15471 return 0;
15472 }
15473
15474 if(!p_igetl(&tempdmap.minimap_2_tile,f))
15475 {
15476 return 0;
15477 }
15478
15479 if(!p_getc(&tempdmap.minimap_2_cset,f))
15480 {
15481 return 0;
15482 }
15483
15484 if(!p_igetl(&tempdmap.largemap_1_tile,f))
15485 {
15486 return 0;
15487 }
15488
15489 if(!p_getc(&tempdmap.largemap_1_cset,f))
15490 {
15491 return 0;
15492 }
15493
15494 if(!p_igetl(&tempdmap.largemap_2_tile,f))
15495 {
15496 return 0;
15497 }
15498
15499 if(!p_getc(&tempdmap.largemap_2_cset,f))
15500 {
15501 return 0;
15502 }
15503
15504 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
15505 {
15506 return 0;
15507 }
15508
15509 if(!p_getc(&tempdmap.tmusictrack,f))
15510 {
15511 return 0;
15512 }
15513
15514 if(!p_getc(&tempdmap.active_subscreen,f))
15515 {
15516 return 0;
15517 }
15518
15519 if(!p_getc(&tempdmap.passive_subscreen,f))
15520 {
15521 return 0;
15522 }
15523
15524 byte disabled[32];
15525 memset(disabled,0,32);
15526
15527 if(!pfread(&disabled, 32, f)) return 0;
15528
15529 for(int32_t j=0; j<MAXITEMS; j++)
15530 {
15531 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
15532 else tempdmap.disableditems[j]=0;
15533 }
15534
15535
15536 if(!p_igetl(&tempdmap.flags,f))
15537 {
15538 return 0;
15539 }
15540 if ( zversion >= 0x255 )
15541 {
15542 if ( section_version >= 14 )
15543 {
15544 //2.55 starts here
15545 if(!p_getc(&tempdmap.sideview,f))
15546 {
15547 return 0;
15548 }
15549 if(!p_igetw(&tempdmap.script,f))
15550 {
15551 return 0;
15552 }
15553 for ( int32_t q = 0; q < 8; q++ )
15554 {
15555 if(!p_igetl(&tempdmap.initD[q],f))
15556 {
15557 return 0;
15558 }
15559
15560 }
15561 for ( int32_t q = 0; q < 8; q++ )
15562 {
15563 for ( int32_t w = 0; w < 65; w++ )
15564 {
15565 if (!p_getc(&tempdmap.initD_label[q][w],f))
15566 {
15567 return 0;
15568 }
15569 }
15570 }
15571 if(!p_igetw(&tempdmap.active_sub_script,f))
15572 {
15573 return 0;
15574 }
15575 if(!p_igetw(&tempdmap.passive_sub_script,f))
15576 {
15577 return 0;
15578 }
15579 for(int32_t q = 0; q < 8; ++q)
15580 {
15581 if(!p_igetl(&tempdmap.sub_initD[q],f))
15582 {
15583 return 0;
15584 }
15585 }
15586 for(int32_t q = 0; q < 8; ++q)
15587 {
15588 for(int32_t w = 0; w < 65; ++w)
15589 {
15590 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
15591 {
15592 return 0;
15593 }
15594 }
15595 }
15596 if(!p_igetw(&tempdmap.onmap_script,f))
15597 {
15598 return 0;
15599 }
15600 for(int32_t q = 0; q < 8; ++q)
15601 {
15602 if(!p_igetl(&tempdmap.onmap_initD[q],f))
15603 {
15604 return 0;
15605 }
15606 }
15607 for(int32_t q = 0; q < 8; ++q)
15608 {
15609 for(int32_t w = 0; w < 65; ++w)
15610 {
15611 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
15612 {
15613 return 0;
15614 }
15615 }
15616 }
15617 if (!p_igetw(&tempdmap.mirrorDMap, f))
15618 {
15619 return 0;
15620 }
15621 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
15622 {
15623 return 0;
15624 }
15625 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
15626 {
15627 return 0;
15628 }
15629 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15630 {
15631 return 0;
15632 }
15633 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15634 {
15635 return 0;
15636 }
15637 }
15638 }
15639 DMaps[index] = tempdmap;
15640
15641 return 1;
15642 }
15643
15644 void dmap_rclick_func(int32_t index, int32_t x, int32_t y)
15645 {
15646 if(((unsigned)index)>MAXDMAPS)
15647 return;
15648
15649 NewMenu rcmenu {
15650 { "&Copy", [&]()
15651 {
15652 copiedDMap = DMaps[index];
15653 dmapcopied = 1;
15654 } },
15655 { "Paste", "&v", [&]()
15656 {
15657 DMaps[index] = copiedDMap;
15658 selectdmap_dlg[2].flags |= D_DIRTY;
15659 saved = false;
15660 }, 0, !dmapcopied },
15661 { "&Save", [&]()
15662 {
15663 if(!prompt_for_new_file_compat("Save DMAP(.zdmap)", "zdmap", NULL,datapath,false))
15664 return;
15665 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
15666 if(!f) return;
15667 writesomedmaps(f,index, index, MAXDMAPS);
15668 pack_fclose(f);
15669 } },
15670 { "&Load", [&]()
15671 {
15672 if(!prompt_for_existing_file_compat("Load DMAP(.zdmap)", "zdmap", NULL,datapath,false))
15673 return;
15674 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
15675 if(!f) return;
15676
15677 if (!readonedmap(f,index))
15678 {
15679 al_trace("Could not read from .zdmap packfile %s\n", temppath);
15680 jwin_alert("ZDMAP File: Error","Could not load the specified DMap.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
15681 }
15682
15683 pack_fclose(f);
15684 selectdmap_dlg[2].flags |= D_DIRTY; //Causes the dialogie list to refresh, updating the item name.
15685 saved = false;
15686 } },
15687 };
15688 rcmenu.pop(x, y);
15689 }
15690
15691
15692 int32_t onDmaps()
15693 {
15694 int32_t ret;
15695 char buf[40];
15696 dmapcopied = 0;
15697 dmap_list_size=MAXDMAPS;
15698 number_list_zero=true;
15699 selectdmap_dlg[0].dp2=get_zc_font(font_lfont);
15700 selectdmap_dlg[2].dp3 = (void *)&dmap_rclick_func;
15701 selectdmap_dlg[2].flags|=(D_USER<<1);
15702
15703 large_dialog(selectdmap_dlg);
15704
15705
15706
15707 ret=do_zqdialog(selectdmap_dlg,2);
15708 dmap* pSelectedDmap = 0;
15709
15710
15711
15712 while(ret!=4&&ret!=0)
15713 {
15714 int32_t d=selectdmap_dlg[2].d1;
15715
15716 if(ret==6) //copy
15717 {
15718 pSelectedDmap = &DMaps[d];
15719 }
15720 else if(ret==7 && pSelectedDmap != 0 ) //paste
15721 {
15722 if( pSelectedDmap != &DMaps[d] )
15723 {
15724 DMaps[d] = *pSelectedDmap;
15725 saved=false;
15726 }
15727 }
15728 else if(ret==5)
15729 {
15730 sprintf(buf,"Delete DMap %d?",d);
15731
15732 if(jwin_alert("Confirm Delete",buf,NULL,NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
15733 {
15734 reset_dmap(d);
15735 saved=false;
15736 }
15737 }
15738 else
15739 {
15740 call_editdmap_dialog(d);
15741 }
15742
15743 ret=do_zqdialog(selectdmap_dlg,2);
15744 }
15745
15746 return D_O_K;
15747 }
15748
15749 static DIALOG editmidi_dlg[] =
15750 {
15751 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15752 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "MIDI Specs", NULL, NULL },
15753 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15754 // 2
15755 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "MIDI:", NULL, NULL },
15756 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15757 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15758 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 35, 0, NULL, NULL, NULL },
15759 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
15760 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
15761 // 8
15762 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
15763 // 9
15764 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
15765 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
15766 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
15767 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
15768 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
15769 // 14
15770 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
15771 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15772 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
15773 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15774 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
15775 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15776 // 20
15777 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
15778 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15779 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
15780 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15781 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
15782 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15783 // 26
15784 { jwin_check_proc, 56, 144+12+12, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Disable Saving", NULL, NULL },
15785 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15786 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15787 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
15788 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15789 };
15790
15791
15792 void edit_tune(int32_t i)
15793 {
15794 // TODO : adapt for non-midi formats
15795 int32_t ret,loop,volume;
15796 byte flags;
15797 int32_t start,loop_start,loop_end;
15798
15799 char title[36];
15800 char volume_str[8];
15801 char start_str[16];
15802 char loop_start_str[16];
15803 char loop_end_str[16];
15804 char len_str[16];
15805 char pos_str[16];
15806
15807 MIDI *data = customtunes[i].data;
15808 get_midi_info(data, &Midi_Info);
15809 volume = customtunes[i].volume;
15810 loop = customtunes[i].loop;
15811 flags = customtunes[i].flags;
15812 start = customtunes[i].start;
15813 loop_start = customtunes[i].loop_start;
15814 loop_end = customtunes[i].loop_end;
15815
15816 strcpy(title,customtunes[i].title);
15817
15818 editmidi_dlg[0].dp2=get_zc_font(font_lfont);
15819
15820 large_dialog(editmidi_dlg);
15821 editmidi_dlg[13].dp2 = font;
15822 editmidi_dlg[12].dp2 = font;
15823 editmidi_dlg[11].dp2 = font;
15824 editmidi_dlg[10].dp2 = font;
15825
15826 do
15827 {
15828 sprintf(volume_str,"%d",volume);
15829 sprintf(start_str,"%d",start);
15830 sprintf(loop_start_str,"%d",loop_start);
15831 sprintf(loop_end_str,"%d",loop_end);
15832 sprintf(len_str,"%d",Midi_Info.len_beats);
15833 sprintf(pos_str,"%ld",midi_pos);
15834
15835 editmidi_dlg[3].dp = data?(void *) "Loaded":(void *) "Empty";
15836 editmidi_dlg[5].dp = title;
15837 editmidi_dlg[7].dp = volume_str;
15838 editmidi_dlg[8].flags = loop?D_SELECTED:0;
15839 editmidi_dlg[10].flags =
15840 editmidi_dlg[11].flags =
15841 editmidi_dlg[12].flags =
15842 editmidi_dlg[13].flags = (data==NULL)?D_DISABLED:D_EXIT;
15843 editmidi_dlg[15].dp = start_str;
15844 editmidi_dlg[17].dp = loop_start_str;
15845 editmidi_dlg[19].dp = loop_end_str;
15846 editmidi_dlg[21].dp = pos_str;
15847 editmidi_dlg[23].dp = len_str;
15848 editmidi_dlg[25].dp = timestr(Midi_Info.len_sec);
15849 editmidi_dlg[26].flags = (flags&tfDISABLESAVE)?D_SELECTED:0;
15850
15851 popup_zqdialog_start();
15852 DIALOG_PLAYER *p = init_dialog(editmidi_dlg,-1);
15853
15854 while(update_dialog(p))
15855 {
15856 custom_vsync();
15857 // text_mode(vc(1));
15858 textprintf_ex(screen,get_zc_font(font_lfont_l),editmidi_dlg[0].x+int32_t(193*1.5),editmidi_dlg[0].y+int32_t(58*1.5),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5ld",midi_pos);
15859 }
15860
15861 ret = shutdown_dialog(p);
15862 popup_zqdialog_end();
15863
15864 loop = editmidi_dlg[8].flags?1:0;
15865 volume = vbound(atoi(volume_str),0,255); // Allegro can't play louder than 255.
15866
15867 start = vbound(atol(start_str),0,zc_max(Midi_Info.len_beats-4,0));
15868 loop_start = vbound(atol(loop_start_str),-1,zc_max(Midi_Info.len_beats-4,-1));
15869 loop_end = vbound(atol(loop_end_str),-1,Midi_Info.len_beats);
15870
15871 if(loop_end>0)
15872 {
15873 loop_end = vbound(loop_end,zc_max(loop_start+4,start+4),Midi_Info.len_beats);
15874 }
15875
15876 flags = 0;
15877 flags |= editmidi_dlg[26].flags&D_SELECTED?tfDISABLESAVE:0;
15878
15879 switch(ret)
15880 {
15881 case 9:
15882 if(prompt_for_existing_file_compat("Load tune","mid;nsf",NULL,temppath,true))
15883 {
15884 zc_stop_midi();
15885
15886 if(data!=NULL && data!=customtunes[i].data)
15887 {
15888 destroy_midi((MIDI*)data);
15889 }
15890
15891 packfile_password("");
15892
15893 if((data=load_midi(temppath))==NULL)
15894 {
15895 jwin_alert("Error","Error loading tune:",temppath,NULL,"Dang",NULL,13,27,get_zc_font(font_lfont));
15896 }
15897 else
15898 {
15899 char *t = get_filename(temppath);
15900 int32_t j;
15901
15902 for(j=0; j<35 && t[j]!=0 && t[j]!='.'; j++)
15903 {
15904 title[j]=t[j];
15905 }
15906
15907 title[j]=0;
15908 }
15909
15910 get_midi_info((MIDI*)data,&Midi_Info);
15911 }
15912
15913 break;
15914
15915 case 10:
15916 zc_stop_midi();
15917 break;
15918
15919 case 12:
15920 if(midi_pos>0)
15921 {
15922 int32_t pos=midi_pos;
15923 zc_stop_midi();
15924 midi_loop_start = -1;
15925 midi_loop_end = -1;
15926 zc_play_midi((MIDI*)data,loop);
15927 zc_set_volume(-1,volume);
15928 midi_loop_start = loop_start;
15929 midi_loop_end = loop_end;
15930
15931 if(midi_loop_end<=0)
15932 {
15933 pos = zc_min(pos+16,Midi_Info.len_beats);
15934 }
15935 else
15936 {
15937 pos = zc_min(pos+16,midi_loop_end);
15938 }
15939
15940 if(pos>0)
15941 {
15942 zc_midi_seek(pos);
15943 }
15944
15945 break;
15946 }
15947
15948 // else play it...
15949
15950 case 13:
15951 if(midi_pos>0)
15952 {
15953 int32_t pos=midi_pos;
15954 zc_stop_midi();
15955 midi_loop_end = -1;
15956 midi_loop_start = -1;
15957 zc_play_midi((MIDI*)data,loop);
15958 zc_set_volume(-1,volume);
15959 midi_loop_end = loop_end;
15960 midi_loop_start = loop_start;
15961
15962 if(midi_loop_end<0)
15963 {
15964 pos = zc_min(pos+64,Midi_Info.len_beats);
15965 }
15966
15967 else
15968 {
15969 pos = zc_min(pos+64,midi_loop_end);
15970 }
15971
15972 if(pos>0)
15973 {
15974 zc_midi_seek(pos);
15975 }
15976
15977 break;
15978 }
15979
15980 // else play it...
15981
15982 case 11:
15983 {
15984 int32_t pos=midi_pos;
15985 zc_stop_midi();
15986 midi_loop_start = -1;
15987 midi_loop_end = -1;
15988 zc_play_midi((MIDI*)data,loop);
15989 zc_set_volume(-1,volume);
15990 zc_midi_seek(pos<0?start:pos);
15991 midi_loop_start = loop_start;
15992 midi_loop_end = loop_end;
15993 }
15994 break;
15995 }
15996 }
15997 while(ret<26&&ret!=0);
15998
15999 zc_stop_midi();
16000
16001 if(ret==27)
16002 {
16003 strcpy(customtunes[i].title,title);
16004 customtunes[i].volume = volume;
16005 customtunes[i].loop = loop;
16006 customtunes[i].start = start;
16007 customtunes[i].loop_start = loop_start;
16008 customtunes[i].loop_end = loop_end;
16009 customtunes[i].flags = flags;
16010
16011 if(data!=customtunes[i].data)
16012 {
16013 if(customtunes[i].data)
16014 destroy_midi(customtunes[i].data);
16015 customtunes[i].data = data;
16016 }
16017
16018 saved=false;
16019 }
16020
16021 if((ret==28||ret==0) && data!=customtunes[i].data)
16022 {
16023 if(data)
16024 {
16025 destroy_midi((MIDI*)data);
16026 }
16027 }
16028 }
16029
16030 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
16031 {
16032 if(msg==MSG_DRAW)
16033 {
16034 int32_t i = d->d1;
16035 int32_t x = d->x+d->w+8;
16036 int32_t y = d->y+4;
16037 int lh = text_height(font);
16038 char const* strs[] = {
16039 "Volume:",
16040 "Loop:",
16041 "Start:",
16042 "Loop Start:",
16043 "Loop End:"
16044 };
16045 int tw = 0;
16046 for(auto str : strs)
16047 {
16048 int w = text_length(font,str);
16049 if(w > tw)
16050 tw = w;
16051 }
16052 int tx = x+tw;
16053 for(int q = 0; q < 5; ++q)
16054 {
16055 textout_right_ex(screen,font,strs[q],tx,y+13+(lh*q),jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
16056 }
16057
16058 textprintf_ex(screen,font,tx+5,y+13+(lh*0),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",customtunes[i].volume);
16059 textprintf_ex(screen,font,tx+5,y+13+(lh*1),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%s",customtunes[i].loop?"On ":"Off");
16060 textprintf_ex(screen,font,tx+5,y+13+(lh*2),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].start);
16061 textprintf_ex(screen,font,tx+5,y+13+(lh*3),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].loop_start);
16062 textprintf_ex(screen,font,tx+5,y+13+(lh*4),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-5d",customtunes[i].loop_end);
16063 }
16064
16065 return jwin_list_proc(msg,d,c);
16066 }
16067
16068 9 static ListData custommidi_list(custommidilist, &a4fonts[font_lfont_l]);
16069
16070 static DIALOG selectmidi_dlg[] =
16071 {
16072 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16073 9 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select music", NULL, NULL },
16074 9 { d_dummy_proc, 160, 56, 0, 8, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16075 9 { d_midilist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &custommidi_list, NULL, NULL },
16076 // { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
16077 // { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &custommidi_list, NULL, NULL },
16078
16079 9 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
16080 9 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
16081 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
16082 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16083 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16084 };
16085
16086 int32_t onMidis()
16087 {
16088 stopMusic();
16089 int32_t ret;
16090 char buf[MIDI_TRACK_BUFFER_SIZE];
16091 number_list_size=MAXCUSTOMTUNES;
16092 number_list_zero=false;
16093 strcpy(temppath,midipath);
16094 selectmidi_dlg[0].dp2=get_zc_font(font_lfont);
16095
16096
16097 large_dialog(selectmidi_dlg);
16098
16099 selectmidi_dlg[2].dp2 = 0;
16100
16101 go();
16102 ret=do_zqdialog(selectmidi_dlg,2);
16103
16104 while(ret!=4&&ret!=0)
16105 {
16106 int32_t d=selectmidi_dlg[2].d1;
16107
16108 if(ret==5)
16109 {
16110 sprintf(buf,"Delete music %d?",d+1);
16111
16112 if(jwin_alert("Confirm Delete",buf,NULL,NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
16113 {
16114 customtunes[d].reset(); // reset_midi(customMIDIs+d);
16115 saved=false;
16116 }
16117 }
16118 else
16119 {
16120 edit_tune(d);
16121 }
16122
16123 ret=do_zqdialog(selectmidi_dlg,2);
16124 }
16125
16126 comeback();
16127 return D_O_K;
16128 }
16129
16130 static DIALOG editmusic_dlg[] =
16131 {
16132 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16133 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Music Specs", NULL, NULL },
16134 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16135 // 2
16136 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Music:", NULL, NULL },
16137 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16138 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16139 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 19, 0, NULL, NULL, NULL },
16140 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
16141 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
16142 // 8
16143 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
16144 // 9
16145 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
16146 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
16147 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
16148 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
16149 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
16150 // 14
16151 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
16152 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16153 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
16154 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16155 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
16156 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16157 // 20
16158 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
16159 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16160 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
16161 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16162 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
16163 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16164 // 26
16165 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16166 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16167 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
16168 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16169 };
16170
16171 int32_t d_musiclist_proc(int32_t msg,DIALOG *d,int32_t c)
16172 {
16173 return jwin_list_proc(msg,d,c);
16174 }
16175
16176 9 static ListData enhancedmusic_list(enhancedmusiclist, &font);
16177
16178 static DIALOG selectmusic_dlg[] =
16179 {
16180 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16181 9 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Enhanced Music", NULL, NULL },
16182 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16183 9 { d_musiclist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enhancedmusic_list, NULL, NULL },
16184 9 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
16185 9 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
16186 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
16187 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16188 };
16189
16190 const char *warptypelist(int32_t index, int32_t *list_size)
16191 {
16192 if(index>=0)
16193 {
16194 if(index>=MAXWARPTYPES)
16195 index=MAXWARPTYPES-1;
16196
16197 return warptype_string[index];
16198 }
16199
16200 *list_size=MAXWARPTYPES;
16201 // *list_size=6;
16202 return NULL;
16203 }
16204
16205 const char *warpeffectlist(int32_t index, int32_t *list_size)
16206 {
16207 if(index>=0)
16208 {
16209 if(index>=MAXWARPEFFECTS)
16210 index=MAXWARPEFFECTS-1;
16211
16212 return warpeffect_string[index];
16213 }
16214
16215 *list_size=MAXWARPEFFECTS;
16216 return NULL;
16217 }
16218
16219 static int32_t warp1_list[] =
16220 {
16221 2,3,4,5,6,7,8,9,10,11,12,13,53,54,63,67,-1
16222 };
16223
16224 static int32_t warp2_list[] =
16225 {
16226 17,18,19,20,21,22,23,24,25,26,27,28,55,56,64,68,-1
16227 };
16228
16229 static int32_t warp3_list[] =
16230 {
16231 29,30,31,32,33,34,35,36,37,38,39,40,57,58,65,69,-1
16232 };
16233
16234 static int32_t warp4_list[] =
16235 {
16236 41,42,43,44,45,46,47,48,49,50,51,52,59,60,66,70,-1
16237 };
16238
16239 static TABPANEL warp_tabs[] =
16240 {
16241 // (text)
16242 { (char *)"A", D_SELECTED, warp1_list, 0, NULL },
16243 { (char *)"B", 0, warp2_list, 0, NULL },
16244 { (char *)"C", 0, warp3_list, 0, NULL },
16245 { (char *)"D", 0, warp4_list, 0, NULL },
16246 { NULL, 0, NULL, 0, NULL }
16247 };
16248
16249 int32_t onTileWarpIndex(int32_t index)
16250 {
16251 int32_t i=-1;
16252
16253 while(warp_tabs[++i].text != NULL)
16254 warp_tabs[i].flags = (i==index ? D_SELECTED : 0);
16255
16256 onTileWarp();
16257 return D_O_K;
16258 }
16259
16260 static char warpr_buf[10];
16261 const char *warprlist(int32_t index, int32_t *list_size)
16262 {
16263 if(index>=0)
16264 {
16265 bound(index,0,3);
16266 sprintf(warpr_buf,"%c",index+0x41);
16267 return warpr_buf;
16268 }
16269
16270 *list_size=4;
16271 return NULL;
16272 }
16273
16274 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t c);
16275
16276 9 static ListData warp_dlg_list(warptypelist, &font);
16277 9 static ListData warp_ret_list(warprlist, &font);
16278
16279 int32_t d_warpdestscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
16280 {
16281 if(msg == MSG_START)
16282 {
16283 d->d1 = -1; //cached val
16284 d->d2 = -1; //cached dmap
16285 d->fg = 0; //cached 'force_16'
16286 }
16287 char* buf = (char*)d->dp;
16288 vector<DIALOG*>* dlgs = (vector<DIALOG*>*)d->dp2;
16289 int* dmap_ptr = (int*) d->dp3;
16290 if(!(buf && dmap_ptr))
16291 return D_O_K;
16292 bool is_overworld = ((DMaps[*dmap_ptr].type&dmfTYPE)==dmOVERW);
16293 int scrw = is_overworld ? 16 : 8, scrh = 9;
16294 const int max = 0x87;
16295 int bufval = zc_xtoi(buf);
16296 int val = vbound(bufval,0,max);
16297 auto& dm = DMaps[*dmap_ptr];
16298 auto val_offset = dm.xoff < 0 ? -dm.xoff : 0;
16299 bool force_16 = d->fg;
16300 if(!is_overworld)
16301 {
16302 if((val&0xF) >= 0x8)
16303 force_16 = true;
16304 else if((val&0xF) < val_offset && (val&0xF0) < 0x80)
16305 force_16 = true;
16306 }
16307 if(force_16) //can't bound, some quests need to warp out of bounds... -Em
16308 {
16309 scrw = 16; //just force show the larger grid instead
16310 val_offset = 0;
16311 }
16312
16313 int xscl = d->w/scrw;
16314 int yscl = d->h/scrh;
16315
16316 int ret = D_O_K;
16317 bool redraw = false;
16318 if(d->d1 != val)
16319 {
16320 redraw = true;
16321 d->d1 = val;
16322 }
16323 if(bufval != val)
16324 {
16325 redraw = true;
16326 sprintf(buf, "%X", val);
16327 }
16328 if(d->d2 != *dmap_ptr)
16329 {
16330 redraw = true;
16331 d->d2 = *dmap_ptr;
16332 }
16333 switch(msg)
16334 {
16335 case MSG_WANTFOCUS:
16336 ret = D_WANTFOCUS;
16337 break;
16338 case MSG_CLICK:
16339 {
16340 d->fg = force_16 ? 1 : 0;
16341 bool redraw2 = false;
16342 while(gui_mouse_b())
16343 {
16344 if(redraw2)
16345 {
16346 broadcast_dialog_message(MSG_DRAW, 0);
16347 redraw2 = false;
16348 }
16349 if(!d->fg && (gui_mouse_b()&2))
16350 {
16351 scrw = 16;
16352 xscl = d->w/scrw;
16353 yscl = d->h/scrh;
16354 val_offset = 0;
16355 d->fg = 1;
16356 redraw2 = true;
16357 }
16358 custom_vsync();
16359 if(!mouse_in_rect(d->x,d->y,d->w,d->h))
16360 continue;
16361 int mx = gui_mouse_x()-d->x, my = gui_mouse_y()-d->y;
16362 int y = vbound(my/yscl,0,scrh-1);
16363 auto offs = y==8 ? 0 : val_offset;
16364 int x = vbound(mx/xscl,offs,scrw-1);
16365 auto val2 = (y*16)+x;
16366 if(val2 > max) //out of bounds in the bottom-right
16367 continue;
16368 val = val2;
16369 if(d->d1 != val)
16370 {
16371 d->d1 = val;
16372 sprintf(buf, "%02X", val);
16373 redraw2 = true;
16374 }
16375 }
16376 redraw = true;
16377 d->fg = 0;
16378 break;
16379 }
16380 case MSG_DRAW:
16381 {
16382 rectfill(screen,d->x,d->y,d->x+d->w-1,d->y+d->h-1,jwin_pal[jcBOX]);
16383 jwin_draw_frame(screen, d->x-2, d->y-2, d->w+4, d->h+4, FR_MENU);
16384 for(int yind = 0; yind < scrh; ++yind)
16385 {
16386 auto gr = (yind < 8 ? dm.grid[yind] : 0);
16387 for(int xind = (yind == 8 ? 0 : val_offset); xind < scrw; ++xind)
16388 {
16389 int scr = xind+(yind*16);
16390 if(scr > max)
16391 continue;
16392 int fr = FR_MENU;
16393 if(scr == d->d1)
16394 fr = FR_GREEN;
16395 else if(!is_overworld && xind < 8 && (gr&(1<<(8-xind-1))))
16396 fr = FR_MENU_INV;
16397 jwin_draw_frame(screen, d->x+(xind*xscl), d->y+(yind*yscl), xscl, yscl, fr);
16398 }
16399 }
16400 break;
16401 }
16402 case MSG_XCHAR:
16403 {
16404 bool on_80 = (val&0xF0) == 0x80;
16405 switch(c>>8)
16406 {
16407 case KEY_UP:
16408 if((val&0xF0) && !(val_offset && on_80 && (val&0xF) < val_offset))
16409 {
16410 val -= 0x10;
16411 redraw = true;
16412 }
16413 ret |= D_USED_CHAR;
16414 break;
16415 case KEY_DOWN:
16416 if((val&0xF0) < ((val&0xF) < 0x8 ? 0x80 : 0x70))
16417 {
16418 val += 0x10;
16419 redraw = true;
16420 }
16421 ret |= D_USED_CHAR;
16422 break;
16423 case KEY_LEFT:
16424 if((val&0xF) > (on_80 ? 0 : val_offset))
16425 {
16426 --val;
16427 redraw = true;
16428 }
16429 ret |= D_USED_CHAR;
16430 break;
16431 case KEY_RIGHT:
16432 if((val&0xF) < scrw-1 && val < 0x87)
16433 {
16434 ++val;
16435 redraw = true;
16436 }
16437 ret |= D_USED_CHAR;
16438 break;
16439 }
16440 if(redraw)
16441 sprintf(buf, "%02X", val);
16442 break;
16443 }
16444 }
16445 if(redraw)
16446 {
16447 if(msg == MSG_IDLE)
16448 broadcast_dialog_message(MSG_DRAW,0);
16449 else
16450 {
16451 d->d1 = d->d2 = -1;
16452 object_message(d,MSG_IDLE,0);
16453 }
16454 }
16455
16456 return ret;
16457 }
16458
16459 int32_t tilewarpdmapxy[6] = {170,38,170,18,170,27};
16460 static DIALOG tilewarp_dlg[] =
16461 {
16462 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16463 9 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16464 9 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
16465 9 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16466 9 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16467 9 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
16468 //5
16469 9 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
16470 9 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16471 9 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16472 9 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16473 9 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16474 //10
16475 9 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
16476 9 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
16477 9 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
16478 9 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16479 9 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
16480 //15
16481 9 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
16482 9 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
16483 9 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
16484 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16485 };
16486
16487 int32_t sidewarpdmapxy[6] = {170,38,170,18,170,27};
16488 static DIALOG sidewarp_dlg[] =
16489 {
16490 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16491 9 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16492 9 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
16493 9 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16494 9 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16495 9 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
16496 //5
16497 9 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
16498 9 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16499 9 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16500 9 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16501 9 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16502 //10
16503 9 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
16504 9 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
16505 9 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
16506 9 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16507 9 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
16508 //15
16509 9 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
16510 9 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
16511 9 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
16512 // 18
16513 9 { d_wflag_proc, 18, 17, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16514 9 { d_wflag_proc, 18, 47, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16515 // 20
16516 9 { d_wflag_proc, 8, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16517 9 { d_wflag_proc, 37, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
16518
16519 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16520 };
16521
16522 int32_t warpringxy[6] = {170,38,170,18,170,27};
16523 static DIALOG warpring_warp_dlg[] =
16524 {
16525 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16526 9 { jwin_win_proc, 0, 0, 302, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16527 9 { jwin_rtext_proc, 57, 25, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
16528 9 { jwin_rtext_proc, 57, 46, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
16529 9 { d_dropdmaplist_proc, 59, 19, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, warpringxy },
16530 9 { jwin_hexedit_proc, 59, 39, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
16531 // 5
16532 9 { jwin_button_proc, 61, 115, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
16533 9 { jwin_button_proc, 121, 115, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
16534 9 { jwin_button_proc, 181, 115, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16535 9 { d_warpdestscrsel_proc, 90, 39, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16536
16537 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16538 };
16539
16540 // Side warp flag procedure
16541 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t)
16542 {
16543 int32_t ret = D_O_K;
16544 switch(msg)
16545 {
16546 case MSG_DRAW:
16547 {
16548 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
16549
16550 if(d->d1==1)
16551 {
16552 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
16553 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
16554
16555 if(d->flags&D_SELECTED)
16556 {
16557 int32_t e=d->d2&3;
16558
16559 if(d->w>d->h)
16560 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16561 else
16562 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16563 }
16564
16565 }
16566 else
16567 {
16568 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
16569 }
16570 }
16571 break;
16572
16573 case MSG_CLICK:
16574 {
16575 if(d->flags & D_DISABLED)
16576 return D_O_K;
16577 bool rclick = gui_mouse_b() & 2;
16578 if(d->d1==1)
16579 {
16580 if(!(d->flags&D_SELECTED))
16581 {
16582 d->flags |= D_SELECTED;
16583 d->d2 &= 0x80;
16584 if (rclick)
16585 d->d2 |= 3;
16586 }
16587 else
16588 {
16589 if((d->d2&3) == (rclick?0:3))
16590 {
16591 d->flags ^= D_SELECTED;
16592 d->d2 &= 0x80;
16593 }
16594 else
16595 {
16596 int32_t f = d->d2&3;
16597 d->d2 &= 0x80;
16598 f += rclick ? -1 : 1;
16599 d->d2 |= f;
16600 }
16601 }
16602 }
16603 else
16604 {
16605 d->flags^=D_SELECTED;
16606 }
16607
16608 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
16609
16610 if(d->d1==1)
16611 {
16612 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
16613 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
16614
16615 if(d->flags&D_SELECTED)
16616 {
16617 int32_t e=d->d2&3;
16618
16619 if(d->w>d->h)
16620 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16621 else
16622 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
16623 }
16624 }
16625 else
16626 {
16627 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
16628 }
16629
16630
16631 while(gui_mouse_b())
16632 {
16633 /* do nothing */
16634 rest(1);
16635 }
16636 ret = D_REDRAWME;
16637 }
16638 break;
16639 }
16640
16641 return ret;
16642 }
16643
16644 int32_t d_dmapscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
16645 {
16646 //these are here to bypass compiler warnings about unused arguments
16647 c=c;
16648
16649 int32_t ret = D_O_K;
16650
16651 switch(msg)
16652 {
16653 case MSG_CLICK:
16654 sprintf((char*)((d+2)->dp),"%X%X",vbound((gui_mouse_y()-d->y)/4,0,7),vbound((gui_mouse_x()-d->x)/(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?4:8),0,(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?15:7)));
16655 object_message(d+2, MSG_DRAW, 0);
16656 break;
16657 }
16658
16659 return ret;
16660 }
16661
16662 int32_t warpdestsel_x=-1;
16663 int32_t warpdestsel_y=-1;
16664 int32_t warpdestmap=-1;
16665 int32_t warpdestscr=-1;
16666
16667 int32_t jwin_minibutton_proc(int32_t msg,DIALOG *d,int32_t c)
16668 {
16669 switch(msg)
16670 {
16671 case MSG_DRAW:
16672 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, false);
16673 return D_O_K;
16674 break;
16675 }
16676
16677 return jwin_button_proc(msg,d,c);
16678 }
16679
16680 int32_t d_triggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
16681 {
16682 static BITMAP *dummy=create_bitmap_ex(8, 1, 1);
16683
16684 switch(msg)
16685 {
16686 case MSG_START:
16687 d->w=gui_textout_ln(dummy, font, (uint8_t *)d->dp, 0, 0, jwin_pal[jcMEDDARK], -1, 0)+4;
16688 d->h=text_height(font)+5;
16689 break;
16690
16691 case MSG_GOTFOCUS:
16692 d->flags&=~D_GOTFOCUS;
16693 break;
16694
16695 }
16696
16697 return jwin_minibutton_proc(msg,d,c);
16698 }
16699
16700 int32_t d_alltriggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
16701 {
16702 DIALOG *temp_d;
16703 int32_t ret=d_triggerbutton_proc(msg,d,c);
16704
16705 switch(msg)
16706 {
16707 case MSG_CLICK:
16708 temp_d=d-1;
16709
16710 while(temp_d->proc==d_triggerbutton_proc)
16711 {
16712 temp_d->flags&=~D_SELECTED;
16713 temp_d->flags|=D_DIRTY;
16714
16715 if(d->flags&D_SELECTED)
16716 {
16717 temp_d->flags|=D_SELECTED;
16718 }
16719
16720 --temp_d;
16721 }
16722
16723 break;
16724 }
16725
16726 return ret;
16727 }
16728
16729 int32_t d_ticsedit_proc(int32_t msg,DIALOG *d,int32_t c)
16730 {
16731 int32_t ret = jwin_edit_proc(msg,d,c);
16732
16733 if(msg==MSG_DRAW)
16734 {
16735 int32_t tics=vbound(atoi((char*)d->dp),0,65535);
16736 sprintf((char*)(d+1)->dp,"%s %s",ticksstr(tics),tics==0?"(No Timed Warp)":" ");
16737 object_message(d+1,MSG_DRAW,c);
16738 }
16739
16740 return ret;
16741 }
16742
16743 9 static ListData warp_effect_list(warpeffectlist,&font);
16744
16745 struct tw_data
16746 {
16747 int twscr[4], twtype[4], twdmap[4], wret[4];
16748 byte oflags;
16749 optional<uint> loaded;
16750
16751 tw_data(mapscr* scr) {load_scr(scr);}
16752 void load_scr(mapscr* scr)
16753 {
16754 oflags = scr->tilewarpoverlayflags;
16755 for(int q = 0; q < 4; ++q)
16756 {
16757 twscr[q] = scr->tilewarpscr[q];
16758 twtype[q] = scr->tilewarptype[q];
16759 twdmap[q] = scr->tilewarpdmap[q];
16760 wret[q] = (scr->warpreturnc >> (2*q))&3;
16761 }
16762 loaded.reset();
16763 }
16764 void save_scr(mapscr* scr)
16765 {
16766 saved=false;
16767 scr->tilewarpoverlayflags = oflags;
16768 scr->warpreturnc = scr->warpreturnc & 0xFF00;
16769 for(int q = 0; q < 4; ++q)
16770 {
16771 scr->tilewarpscr[q] = twscr[q];
16772 scr->tilewarptype[q] = twtype[q];
16773 scr->tilewarpdmap[q] = twdmap[q];
16774 scr->warpreturnc |= wret[q] << (2*q);
16775 }
16776 }
16777
16778 void load(uint ind)
16779 {
16780 if(ind >= 4) return;
16781 loaded = ind;
16782 tilewarp_dlg[4].d1 = twtype[ind];
16783 tilewarp_dlg[5].d1 = twdmap[ind];
16784 char* buf = (char*)tilewarp_dlg[6].dp;
16785 sprintf(buf,"%02X",twscr[ind]);
16786 tilewarp_dlg[11].d1 = wret[ind];
16787 SETFLAG(tilewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16788 for(int q = 0; q < 4; ++q)
16789 SETFLAG(tilewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16790 }
16791 void save(uint ind)
16792 {
16793 if(ind >= 4) return;
16794 twtype[ind] = tilewarp_dlg[4].d1;
16795 twdmap[ind] = tilewarp_dlg[5].d1;
16796 char* buf = (char*)tilewarp_dlg[6].dp;
16797 twscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16798 wret[ind] = tilewarp_dlg[11].d1;
16799 set_bit(&oflags, ind, tilewarp_dlg[12].flags & D_SELECTED);
16800 }
16801 void save()
16802 {
16803 if(loaded)
16804 save(*loaded);
16805 }
16806 void swap(uint ind)
16807 {
16808 if(ind >= 4) return;
16809 if(loaded)
16810 {
16811 save(*loaded);
16812 if(*loaded == ind)
16813 return;
16814 }
16815 load(ind);
16816 }
16817 };
16818 int32_t onTileWarp()
16819 {
16820 restore_mouse();
16821 tilewarp_dlg[0].dp=(void *) "Tile Warp";
16822 tilewarp_dlg[0].dp2=get_zc_font(font_lfont);
16823
16824 mapscr* mptr = Map.CurrScr();
16825 char buf[10];
16826 tilewarp_dlg[6].dp=buf;
16827 tilewarp_dlg[13].dp = buf;
16828 tilewarp_dlg[13].dp3 = &tilewarp_dlg[5].d1;
16829
16830 vector<DIALOG*> dlgs;
16831 dlgs.push_back(&tilewarp_dlg[5]);
16832 dlgs.push_back(&tilewarp_dlg[6]);
16833 tilewarp_dlg[13].dp2 = &dlgs;
16834
16835 tw_data data(mptr);
16836 data.load(0);
16837
16838 dmap_list_size=MAXDMAPS;
16839 dmap_list_zero=true;
16840
16841 large_dialog(tilewarp_dlg);
16842
16843 bool running = true;
16844 int ret;
16845 do
16846 {
16847 ret = do_zqdialog(tilewarp_dlg,-1);
16848 switch(ret)
16849 {
16850 // OK, GO
16851 case 7: case 8:
16852 running = false;
16853 data.save();
16854 data.save_scr(mptr);
16855 refresh(rMENU);
16856 break;
16857 //Cancel
16858 case 9:
16859 running = false;
16860 break;
16861 //A,B,C,D
16862 case 14: case 15: case 16: case 17:
16863 data.swap(ret-14);
16864 break;
16865 }
16866 }
16867 while(running);
16868
16869 if(ret==8) //GO
16870 {
16871 int32_t index = *data.loaded;
16872
16873 FlashWarpSquare = -1;
16874 int32_t tm = Map.getCurrMap();
16875 int32_t ts = Map.getCurrScr();
16876 int32_t thistype = mptr->tilewarptype[index];
16877 Map.dowarp(0,index);
16878
16879 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtCAVE && thistype != wtSCROLL)
16880 {
16881 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(index*2))&3;
16882 FlashWarpClk = 32;
16883 }
16884
16885 refresh(rALL);
16886 }
16887
16888 return D_O_K;
16889 }
16890
16891 struct sw_data
16892 {
16893 int swscr[4], swtype[4], swdmap[4], wret[4];
16894 byte oflags;
16895 optional<uint> loaded;
16896
16897 sw_data(mapscr* scr) {load_scr(scr);}
16898 void load_scr(mapscr* scr)
16899 {
16900 oflags = scr->sidewarpoverlayflags;
16901 for(int q = 0; q < 4; ++q)
16902 {
16903 swscr[q] = scr->sidewarpscr[q];
16904 swtype[q] = scr->sidewarptype[q];
16905 swdmap[q] = scr->sidewarpdmap[q];
16906 wret[q] = (scr->warpreturnc >> (2*(q+4)))&3;
16907 }
16908 loaded.reset();
16909
16910 for(int32_t i=0; i<4; i++)
16911 {
16912 sidewarp_dlg[18+i].d2 = 0x80;
16913 if(scr->flags2&(1<<i))
16914 {
16915 sidewarp_dlg[18+i].flags = D_SELECTED ;
16916 sidewarp_dlg[18+i].d2 |= (scr->sidewarpindex>>(2*i))&3;
16917 }
16918 else
16919 {
16920 sidewarp_dlg[18+i].flags = 0;
16921 }
16922 }
16923 }
16924 void save_scr(mapscr* scr)
16925 {
16926 saved=false;
16927 scr->sidewarpoverlayflags = oflags;
16928 scr->warpreturnc = scr->warpreturnc & 0x00FF;
16929 for(int q = 0; q < 4; ++q)
16930 {
16931 scr->sidewarpscr[q] = swscr[q];
16932 scr->sidewarptype[q] = swtype[q];
16933 scr->sidewarpdmap[q] = swdmap[q];
16934 scr->warpreturnc |= wret[q] << (2*(q+4));
16935 }
16936
16937 scr->flags2 &= ~0xF;
16938 scr->sidewarpindex = 0;
16939 for(int32_t i=0; i<4; i++)
16940 {
16941 if(sidewarp_dlg[18+i].flags & D_SELECTED)
16942 scr->flags2 |= 1<<i;
16943 scr->sidewarpindex |= (sidewarp_dlg[18+i].d2&3) << (i*2);
16944 }
16945 }
16946
16947 void load(uint ind)
16948 {
16949 if(ind >= 4) return;
16950 loaded = ind;
16951 sidewarp_dlg[4].d1 = swtype[ind];
16952 sidewarp_dlg[5].d1 = swdmap[ind];
16953 char* buf = (char*)sidewarp_dlg[6].dp;
16954 sprintf(buf,"%02X",swscr[ind]);
16955 sidewarp_dlg[11].d1 = wret[ind];
16956 SETFLAG(sidewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16957 for(int q = 0; q < 4; ++q)
16958 SETFLAG(sidewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16959 }
16960 void save(uint ind)
16961 {
16962 if(ind >= 4) return;
16963 swtype[ind] = sidewarp_dlg[4].d1;
16964 swdmap[ind] = sidewarp_dlg[5].d1;
16965 char* buf = (char*)sidewarp_dlg[6].dp;
16966 swscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16967 wret[ind] = sidewarp_dlg[11].d1;
16968 set_bit(&oflags, ind, sidewarp_dlg[12].flags & D_SELECTED);
16969 }
16970 void save()
16971 {
16972 if(loaded)
16973 save(*loaded);
16974 }
16975 void swap(uint ind)
16976 {
16977 if(ind >= 4) return;
16978 if(loaded)
16979 {
16980 save(*loaded);
16981 if(*loaded == ind)
16982 return;
16983 }
16984 load(ind);
16985 }
16986 };
16987 int32_t onSideWarp()
16988 {
16989 restore_mouse();
16990 sidewarp_dlg[0].dp=(void *) "Side Warp";
16991 sidewarp_dlg[0].dp2=get_zc_font(font_lfont);
16992
16993 mapscr* mptr = Map.CurrScr();
16994 char buf[10];
16995 sidewarp_dlg[6].dp=buf;
16996 sidewarp_dlg[13].dp = buf;
16997 sidewarp_dlg[13].dp3 = &sidewarp_dlg[5].d1;
16998
16999 vector<DIALOG*> dlgs;
17000 dlgs.push_back(&sidewarp_dlg[5]);
17001 dlgs.push_back(&sidewarp_dlg[6]);
17002 sidewarp_dlg[13].dp2 = &dlgs;
17003
17004 sw_data data(mptr);
17005 data.load(0);
17006
17007 dmap_list_size=MAXDMAPS;
17008 dmap_list_zero=true;
17009
17010 large_dialog(sidewarp_dlg);
17011
17012 bool running = true;
17013 int ret;
17014 do
17015 {
17016 ret = do_zqdialog(sidewarp_dlg,-1);
17017 switch(ret)
17018 {
17019 // OK, GO
17020 case 7: case 8:
17021 running = false;
17022 data.save();
17023 data.save_scr(mptr);
17024 refresh(rMENU);
17025 break;
17026 //Cancel
17027 case 9:
17028 running = false;
17029 break;
17030 //A,B,C,D
17031 case 14: case 15: case 16: case 17:
17032 data.swap(ret-14);
17033 break;
17034 }
17035 }
17036 while(running);
17037
17038 if(ret==8) //GO
17039 {
17040 int32_t index = *data.loaded;
17041
17042 FlashWarpSquare = -1;
17043 int32_t tm = Map.getCurrMap();
17044 int32_t ts = Map.getCurrScr();
17045
17046 int32_t thistype = mptr->sidewarptype[index];
17047 Map.dowarp(1,index);
17048
17049 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtSCROLL)
17050 {
17051 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(8+index*2))&3;
17052 FlashWarpClk = 0x20;
17053 }
17054
17055 refresh(rALL);
17056 }
17057
17058 return D_O_K;
17059 }
17060
17061
17062
17063 const char *dirlist(int32_t index, int32_t *list_size)
17064 {
17065 if(index>=0)
17066 {
17067 if(index>3)
17068 index=3;
17069
17070 return mazedirstr[index];
17071 }
17072
17073 *list_size=4;
17074 return NULL;
17075 }
17076
17077 9 static ListData path_dlg_list(dirlist, &font);
17078
17079 static DIALOG path_dlg[] =
17080 {
17081 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17082 9 { jwin_win_proc, 80, 57, 161, 164, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Maze Path", NULL, NULL },
17083 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17084 9 { jwin_text_proc, 94, 106, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17085 9 { jwin_text_proc, 94, 124, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17086 9 { jwin_text_proc, 94, 142, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17087 9 { jwin_text_proc, 94, 160, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "4th", NULL, NULL },
17088 9 { jwin_text_proc, 94, 178, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Exit", NULL, NULL },
17089 9 { jwin_droplist_proc, 140, 102, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17090 9 { jwin_droplist_proc, 140, 120, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17091 9 { jwin_droplist_proc, 140, 138, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17092 9 { jwin_droplist_proc, 140, 156, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17093 9 { jwin_droplist_proc, 140, 174, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
17094 9 { jwin_button_proc, 90, 194, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17095 9 { jwin_button_proc, 170, 194, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17096 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
17097 9 { jwin_text_proc, 87, 82, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "A Lost Woods-style maze screen", NULL, NULL },
17098 9 { jwin_text_proc, 87, 92, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "with a normal and secret exit.", NULL, NULL },
17099 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17100 };
17101
17102 int32_t onPath()
17103 {
17104 restore_mouse();
17105 path_dlg[0].dp2=get_zc_font(font_lfont);
17106
17107 for(int32_t i=0; i<4; i++)
17108 path_dlg[i+7].d1 = Map.CurrScr()->path[i];
17109
17110 path_dlg[11].d1 = Map.CurrScr()->exitdir;
17111
17112 large_dialog(path_dlg);
17113
17114 int32_t ret;
17115
17116 do
17117 {
17118 ret=do_zqdialog(path_dlg,7);
17119
17120 if(ret==12) for(int32_t i=0; i<4; i++)
17121 {
17122 if(path_dlg[i+7].d1 == path_dlg[11].d1)
17123 {
17124 if(jwin_alert("Exit Problem","One of the path's directions is","also the normal Exit direction! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
17125 ret = -1;
17126
17127 break;
17128 }
17129 }
17130 }
17131 while(ret == -1);
17132
17133 if(ret==12)
17134 {
17135 saved=false;
17136
17137 for(int32_t i=0; i<4; i++)
17138 Map.CurrScr()->path[i] = path_dlg[i+7].d1;
17139
17140 Map.CurrScr()->exitdir = path_dlg[11].d1;
17141
17142 if(!(Map.CurrScr()->flags&fMAZE))
17143 if(jwin_alert("Screen Flag","Turn on the 'Use Maze Path' Screen Flag?","(Go to 'Screen Data' to turn it off.)",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==1)
17144 Map.CurrScr()->flags |= fMAZE;
17145 }
17146
17147 refresh(rMAP+rMENU);
17148 return D_O_K;
17149 }
17150
17151
17152
17153 static DIALOG editinfo_dlg[] =
17154 {
17155 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17156 9 { jwin_win_proc, 0, 10, 208, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17157 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17158 9 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17159 9 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17160 9 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17161 9 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17162 9 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17163 9 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17164 // 8
17165 9 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17166 9 { d_ndroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17167 9 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17168 9 { d_ndroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17169 9 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17170 9 { d_ndroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17171 9 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17172 9 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
17173 // 16
17174 9 { jwin_button_proc, 34, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17175 9 { jwin_button_proc, 114, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17176 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17177 };
17178
17179 void EditInfoType(int32_t index)
17180 {
17181 char ps1[6],ps2[6],ps3[6];
17182 char infoname[33];
17183 char caption[40];
17184
17185 int32_t str1, str2, str3;
17186
17187 sprintf(caption,"Info Data %d",index);
17188 editinfo_dlg[0].dp = caption;
17189 editinfo_dlg[0].dp2 = get_zc_font(font_lfont);
17190
17191 sprintf(ps1,"%d",QMisc.info[index].price[0]);
17192 sprintf(ps2,"%d",QMisc.info[index].price[1]);
17193 sprintf(ps3,"%d",QMisc.info[index].price[2]);
17194 strncpy(infoname,QMisc.info[index].name,32);
17195 infoname[32] = 0;
17196 editinfo_dlg[8].dp = ps1;
17197 editinfo_dlg[10].dp = ps2;
17198 editinfo_dlg[12].dp = ps3;
17199 editinfo_dlg[15].dp = infoname;
17200 str1 = QMisc.info[index].str[0];
17201 str2 = QMisc.info[index].str[1];
17202 str3 = QMisc.info[index].str[2];
17203 editinfo_dlg[9].d1 = MsgStrings[str1].listpos;
17204 editinfo_dlg[11].d1 = MsgStrings[str2].listpos;
17205 editinfo_dlg[13].d1 = MsgStrings[str3].listpos;
17206 ListData msgs_list(msgslist2, &a4fonts[font_lfont_l]);
17207 editinfo_dlg[9].dp =
17208 editinfo_dlg[11].dp =
17209 editinfo_dlg[13].dp = (void *) &msgs_list;
17210
17211 large_dialog(editinfo_dlg);
17212
17213 int32_t ret = do_zqdialog(editinfo_dlg,-1);
17214
17215 if(ret==16)
17216 {
17217 saved=false;
17218 QMisc.info[index].price[0] = vbound(atoi(ps1), 0, 65535);
17219 QMisc.info[index].price[1] = vbound(atoi(ps2), 0, 65535);
17220 QMisc.info[index].price[2] = vbound(atoi(ps3), 0, 65535);
17221 strncpy(QMisc.info[index].name,infoname,32);
17222 str1 = editinfo_dlg[9].d1;
17223 str2 = editinfo_dlg[11].d1;
17224 str3 = editinfo_dlg[13].d1;
17225 QMisc.info[index].str[0] = msg_at_pos(str1);
17226 QMisc.info[index].str[1] = msg_at_pos(str2);
17227 QMisc.info[index].str[2] = msg_at_pos(str3);
17228
17229 //move 0s to the end
17230 word swaptmp;
17231
17232 if(QMisc.info[index].str[0] == 0)
17233 {
17234 //possibly permute the infos
17235 if(QMisc.info[index].str[1] != 0)
17236 {
17237 //swap
17238 swaptmp = QMisc.info[index].str[0];
17239 QMisc.info[index].str[0] = QMisc.info[index].str[1];
17240 QMisc.info[index].str[1] = swaptmp;
17241 swaptmp = QMisc.info[index].price[0];
17242 QMisc.info[index].price[0] = QMisc.info[index].price[1];
17243 QMisc.info[index].price[1] = swaptmp;
17244 }
17245 else if(QMisc.info[index].str[2] != 0)
17246 {
17247 //move info 0 to 1, 1 to 2, and 2 to 0
17248 swaptmp = QMisc.info[index].str[0];
17249 QMisc.info[index].str[0] = QMisc.info[index].str[2];
17250 QMisc.info[index].str[2] = QMisc.info[index].str[1];
17251 QMisc.info[index].str[1] = swaptmp;
17252 swaptmp = QMisc.info[index].price[0];
17253 QMisc.info[index].price[0] = QMisc.info[index].price[2];
17254 QMisc.info[index].price[2] = QMisc.info[index].price[1];
17255 QMisc.info[index].price[1] = swaptmp;
17256 }
17257 }
17258
17259 if(QMisc.info[index].str[1] == 0 && QMisc.info[index].str[2] != 0)
17260 //swap
17261 {
17262 swaptmp = QMisc.info[index].str[1];
17263 QMisc.info[index].str[1] = QMisc.info[index].str[2];
17264 QMisc.info[index].str[2] = swaptmp;
17265 swaptmp = QMisc.info[index].price[1];
17266 QMisc.info[index].price[1] = QMisc.info[index].price[2];
17267 QMisc.info[index].price[2] = swaptmp;
17268 }
17269 }
17270 }
17271
17272 int32_t onInfoTypes()
17273 {
17274 info_list_size = 256;
17275
17276 int32_t index = select_data("Info Types",0,infolist,"Edit","Done",get_zc_font(font_lfont));
17277
17278 while(index!=-1)
17279 {
17280 EditInfoType(index);
17281
17282 index = select_data("Info Types",index,infolist,"Edit","Done",get_zc_font(font_lfont));
17283 }
17284
17285 return D_O_K;
17286 }
17287
17288
17289
17290 //This dialogie is self-contained, and does not use dialogue control numbers in a separate array to generate its fields.
17291 static DIALOG editshop_dlg[] =
17292 {
17293 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17294 9 { jwin_win_proc, 0, 10, 221, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17295 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17296 9 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
17297 9 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
17298 9 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
17299 9 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17300 9 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17301 9 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
17302 // 8
17303 9 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17304 9 { d_nidroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17305 9 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17306 9 { d_nidroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17307 9 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17308 9 { d_nidroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17309 9 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17310 9 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
17311
17312 // 16
17313 9 { jwin_button_proc, 40, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17314 9 { jwin_button_proc, 121, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17315 //18
17316 9 { jwin_text_proc, 130, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17317 9 { jwin_text_proc, 130, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17318 9 { jwin_text_proc, 130, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
17319 // 21
17320 9 { jwin_edit_proc, 155, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17321 9 { jwin_edit_proc, 155, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17322 9 { jwin_edit_proc, 155, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17323
17324 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17325 };
17326
17327 void EditShopType(int32_t index)
17328 {
17329
17330 build_bii_list(true);
17331 char ps1[6],ps2[6],ps3[6];
17332 char info1[6],info2[6],info3[6];
17333 char shopname[32];
17334 char caption[40];
17335
17336 sprintf(caption,"Shop Data %d",index);
17337 editshop_dlg[0].dp = caption;
17338 editshop_dlg[0].dp2=get_zc_font(font_lfont);
17339
17340 sprintf(ps1,"%d",QMisc.shop[index].price[0]);
17341 sprintf(ps2,"%d",QMisc.shop[index].price[1]);
17342 sprintf(ps3,"%d",QMisc.shop[index].price[2]);
17343
17344 sprintf(info1,"%d",QMisc.shop[index].str[0]);
17345 sprintf(info2,"%d",QMisc.shop[index].str[1]);
17346 sprintf(info3,"%d",QMisc.shop[index].str[2]);
17347
17348 sprintf(shopname,"%s",QMisc.shop[index].name);
17349 editshop_dlg[8].dp = ps1;
17350 editshop_dlg[10].dp = ps2;
17351 editshop_dlg[12].dp = ps3;
17352 editshop_dlg[15].dp = shopname;
17353
17354 editshop_dlg[21].dp = info1;
17355 editshop_dlg[22].dp = info2;
17356 editshop_dlg[23].dp = info3;
17357
17358 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
17359
17360 editshop_dlg[9].dp = (void *) &item_list;
17361 editshop_dlg[11].dp = (void *) &item_list;
17362 editshop_dlg[13].dp = (void *) &item_list;
17363
17364 for(int32_t i=0; i<3; ++i)
17365 {
17366 if(QMisc.shop[index].hasitem[i])
17367 {
17368 for(int32_t j=0; j<bii_cnt; j++)
17369 {
17370 if(bii[j].i == QMisc.shop[index].item[i])
17371 {
17372 editshop_dlg[9+(i<<1)].d1 = j;
17373 }
17374 }
17375 }
17376 else
17377 {
17378 editshop_dlg[9+(i<<1)].d1 = -2;
17379 }
17380 }
17381
17382 large_dialog(editshop_dlg);
17383
17384 int32_t ret = do_zqdialog(editshop_dlg,-1);
17385
17386 if(ret==16)
17387 {
17388 saved=false;
17389 QMisc.shop[index].price[0] = vbound(atoi(ps1), 0, 65535);
17390 QMisc.shop[index].price[1] = vbound(atoi(ps2), 0, 65535);
17391 QMisc.shop[index].price[2] = vbound(atoi(ps3), 0, 65535);
17392
17393 QMisc.shop[index].str[0] = vbound(atoi(info1), 0, 65535);
17394 QMisc.shop[index].str[1] = vbound(atoi(info2), 0, 65535);
17395 QMisc.shop[index].str[2] = vbound(atoi(info3), 0, 65535);
17396
17397 snprintf(QMisc.shop[index].name, 32, "%s",shopname);
17398
17399 for(int32_t i=0; i<3; ++i)
17400 {
17401 if(bii[editshop_dlg[9+(i<<1)].d1].i == -2)
17402 {
17403 QMisc.shop[index].hasitem[i] = 0;
17404 QMisc.shop[index].item[i] = 0;
17405 QMisc.shop[index].price[i] = 0;
17406 }
17407 else
17408 {
17409 QMisc.shop[index].hasitem[i] = 1;
17410 QMisc.shop[index].item[i] = bii[editshop_dlg[9+(i<<1)].d1].i;
17411 }
17412 }
17413
17414 //filter all the 0 items to the end (yeah, bubble sort; sue me)
17415 word swaptmp;
17416
17417 for(int32_t j=0; j<3-1; j++)
17418 {
17419 for(int32_t k=0; k<2-j; k++)
17420 {
17421 if(QMisc.shop[index].hasitem[k]==0)
17422 {
17423 swaptmp = QMisc.shop[index].item[k];
17424 QMisc.shop[index].item[k] = QMisc.shop[index].item[k+1];
17425 QMisc.shop[index].item[k+1] = swaptmp;
17426 swaptmp = QMisc.shop[index].price[k];
17427 QMisc.shop[index].price[k] = QMisc.shop[index].price[k+1];
17428 QMisc.shop[index].price[k+1] = swaptmp;
17429 swaptmp = QMisc.shop[index].hasitem[k];
17430 QMisc.shop[index].hasitem[k] = QMisc.shop[index].item[k+1];
17431 QMisc.shop[index].hasitem[k+1] = swaptmp;
17432 }
17433 }
17434 }
17435 }
17436 }
17437
17438 int32_t onShopTypes()
17439 {
17440 shop_list_size = 256;
17441
17442 int32_t index = select_data("Shop Types",0,shoplist,"Edit","Done",get_zc_font(font_lfont));
17443
17444 while(index!=-1)
17445 {
17446 EditShopType(index);
17447 index = select_data("Shop Types",index,shoplist,"Edit","Done",get_zc_font(font_lfont));
17448 }
17449
17450 return D_O_K;
17451 }
17452
17453 void call_bottle_dlg(int32_t index);
17454 int32_t onBottleTypes()
17455 {
17456 bottle_list_size = 64;
17457 int32_t index = 0;
17458
17459 while(index > -1)
17460 {
17461 index = select_data("Bottle Types", index, bottlelist, "Edit", "Done", get_zc_font(font_lfont));
17462 if(index > -1)
17463 call_bottle_dlg(index);
17464 }
17465
17466 return D_O_K;
17467 }
17468
17469 void call_bottleshop_dlg(int32_t index);
17470 int32_t onBottleShopTypes()
17471 {
17472 bottleshop_list_size = 256;
17473 int32_t index = 0;
17474
17475 while(index > -1)
17476 {
17477 index = select_data("Bottle Shop Types", index, bottleshoplist, "Edit", "Done", get_zc_font(font_lfont));
17478 if(index > -1)
17479 call_bottleshop_dlg(index);
17480 }
17481
17482 return D_O_K;
17483 }
17484
17485
17486 static char item_drop_set_str_buf[70];
17487 int32_t item_drop_set_list_size=MAXITEMDROPSETS;
17488
17489 const char *itemdropsetlist(int32_t index, int32_t *list_size)
17490 {
17491 if(index>=0)
17492 {
17493 bound(index,0,item_drop_set_list_size-1);
17494 sprintf(item_drop_set_str_buf,"%3d: %s",index,item_drop_sets[index].name);
17495 return item_drop_set_str_buf;
17496 }
17497
17498 *list_size=item_drop_set_list_size;
17499 return NULL;
17500 }
17501
17502 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c);
17503
17504 static int32_t edititemdropset_1_list[] =
17505 {
17506 // dialog control number
17507 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28, -1
17508 };
17509
17510 static int32_t edititemdropset_2_list[] =
17511 {
17512 // dialog control number
17513 12, 13, 29, 30, 31, 32, 33,34,35,36,37,38,39,40,41,42,43, -1
17514 };
17515
17516 static TABPANEL edititemdropset_tabs[] =
17517 {
17518 // (text)
17519 { (char *)" Page 1 ", D_SELECTED, edititemdropset_1_list, 0, NULL },
17520 { (char *)" Page 2 ", 0, edititemdropset_2_list, 0, NULL },
17521 { NULL, 0, NULL, 0, NULL }
17522 };
17523
17524 static DIALOG edititemdropset_dlg[] =
17525 {
17526 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17527 9 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17528 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17529
17530 // 2
17531 9 { jwin_button_proc, 89, 213, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
17532 9 { jwin_button_proc, 169, 213, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17533
17534 // 4
17535 9 { jwin_text_proc, 9, 29, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
17536 9 { jwin_edit_proc, 39, 25, 275, 16, vc(12), vc(1), 0, 0, 32, 0, NULL, NULL, NULL },
17537 9 { jwin_text_proc, 9, 47, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Nothing Chance:", NULL, NULL },
17538 9 { d_itemdropedit_proc, 84, 43, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17539
17540 9 { jwin_tab_proc, 4, 65, 312, 143, vc(0), vc(15), 0, 0, 0, 0, (void *) edititemdropset_tabs, NULL, (void *)edititemdropset_dlg },
17541 9 { jwin_text_proc, 114, 43+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17542 // 10
17543 9 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
17544 9 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
17545 9 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
17546 9 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
17547
17548 // 14
17549 9 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17550 9 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17551 9 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17552 9 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17553 9 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17554 9 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17555 9 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17556 9 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17557 9 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17558 9 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17559 9 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17560 9 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17561 9 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17562 9 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17563 9 { jwin_text_proc, 37, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17564 // 29
17565 9 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17566 9 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17567 9 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17568 9 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17569 9 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17570 9 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17571 9 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17572 9 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17573 9 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17574 9 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17575 9 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17576 9 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17577 9 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
17578 9 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
17579 9 { jwin_text_proc, 39, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
17580 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17581 };
17582
17583 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c)
17584 {
17585 int32_t ret = jwin_edit_proc(msg,d,c);
17586
17587 if(msg==MSG_DRAW)
17588 {
17589 int32_t t = atoi((char*)edititemdropset_dlg[7].dp);
17590
17591 for(int32_t i=0; i<10; ++i)
17592 {
17593 t += atoi((char*)edititemdropset_dlg[14+(i*3)].dp);
17594 }
17595
17596 {
17597 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[7].dp) / zc_max(t,1));
17598 sprintf((char*)edititemdropset_dlg[9].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
17599 object_message(&edititemdropset_dlg[9],MSG_DRAW,c);
17600 }
17601
17602 for(int32_t i=0; i<10; ++i)
17603 {
17604 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[14+(i*3)].dp) / zc_max(t,1));
17605 sprintf((char*)edititemdropset_dlg[16+(i*3)].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
17606 object_message(&edititemdropset_dlg[16+(i*3)],MSG_DRAW,c);
17607 }
17608
17609 }
17610
17611 return ret;
17612 }
17613
17614 void EditItemDropSet(int32_t index)
17615 {
17616 build_bii_list(true);
17617 char chance[11][10];
17618 char itemdropsetname[64];
17619 char caption[40];
17620 char percent_str[11][5];
17621
17622 sprintf(caption,"Item Drop Set Data %d",index);
17623 edititemdropset_dlg[0].dp = caption;
17624 edititemdropset_dlg[0].dp2=get_zc_font(font_lfont);
17625
17626 sprintf(itemdropsetname,"%s",item_drop_sets[index].name);
17627 edititemdropset_dlg[5].dp = itemdropsetname;
17628
17629 sprintf(chance[0],"%d",item_drop_sets[index].chance[0]);
17630 edititemdropset_dlg[7].dp = chance[0];
17631
17632 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
17633 sprintf(percent_str[0]," ");
17634 edititemdropset_dlg[9].dp = percent_str[0];
17635
17636 for(int32_t i=0; i<10; ++i)
17637 {
17638 sprintf(chance[i+1],"%d",item_drop_sets[index].chance[i+1]);
17639 edititemdropset_dlg[14+(i*3)].dp = chance[i+1];
17640 edititemdropset_dlg[15+(i*3)].dp = (void *) &item_list;
17641 sprintf(percent_str[i+1]," ");
17642 edititemdropset_dlg[16+(i*3)].dp = percent_str[i+1];
17643
17644 if(item_drop_sets[index].chance[i+1]==0)
17645 {
17646 edititemdropset_dlg[15+(i*3)].d1 = -2;
17647 }
17648 else
17649 {
17650 for(int32_t j=0; j<bii_cnt; j++)
17651 {
17652 if(bii[j].i == item_drop_sets[index].item[i])
17653 {
17654 edititemdropset_dlg[15+(i*3)].d1 = j;
17655 }
17656 }
17657 }
17658 }
17659
17660 large_dialog(edititemdropset_dlg);
17661
17662 int32_t ret = do_zqdialog(edititemdropset_dlg,-1);
17663
17664 if(ret==2)
17665 {
17666 saved=false;
17667
17668 sprintf(item_drop_sets[index].name,"%s",itemdropsetname);
17669
17670 item_drop_sets[index].chance[0]=atoi(chance[0]);
17671
17672 for(int32_t i=0; i<10; ++i)
17673 {
17674 item_drop_sets[index].chance[i+1]=atoi(chance[i+1]);
17675
17676 if(bii[edititemdropset_dlg[15+(i*3)].d1].i == -2)
17677 {
17678 item_drop_sets[index].chance[i+1]=0;
17679 }
17680 else
17681 {
17682 item_drop_sets[index].item[i] = bii[edititemdropset_dlg[15+(i*3)].d1].i;
17683 }
17684
17685 if(item_drop_sets[index].chance[i+1]==0)
17686 {
17687 item_drop_sets[index].item[i] = 0;
17688 }
17689 }
17690 }
17691 }
17692
17693 6 int32_t count_item_drop_sets()
17694 {
17695 6 int32_t count=0;
17696 6 bool found=false;
17697
17698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
1463 for(count=255; (count>0); --count)
17699 {
17700
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 16034 times.
17491 for(int32_t i=0; (i<11); ++i)
17701 {
17702
2/2
✓ Branch 0 taken 16028 times.
✓ Branch 1 taken 6 times.
16034 if(item_drop_sets[count].chance[i]!=0)
17703 {
17704 6 found=true;
17705 6 break;
17706 }
17707 16028 }
17708
17709
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1457 times.
1463 if(found)
17710 {
17711 6 break;
17712 }
17713 1457 }
17714
17715 6 return count+1;
17716 }
17717
17718 int32_t onItemDropSets()
17719 {
17720 item_drop_set_list_size = MAXITEMDROPSETS;
17721
17722 int32_t index = select_data("Item Drop Sets",0,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
17723
17724 while(index!=-1)
17725 {
17726 EditItemDropSet(index);
17727 index = select_data("Item Drop Sets",index,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
17728 }
17729
17730 return D_O_K;
17731 }
17732
17733 int32_t curr_ring = 0;
17734
17735 void EditWarpRingScr(int32_t ring,int32_t index)
17736 {
17737 char caption[40],buf[10];
17738 restore_mouse();
17739
17740 sprintf(caption,"Ring %d Warp %d",ring,index+1);
17741 warpring_warp_dlg[0].dp = (void *)caption;
17742 warpring_warp_dlg[0].dp2=get_zc_font(font_lfont);
17743
17744 sprintf(buf,"%02X",QMisc.warp[ring].scr[index]);
17745 warpring_warp_dlg[3].d1 = QMisc.warp[ring].dmap[index];
17746 warpring_warp_dlg[4].dp = buf;
17747 warpring_warp_dlg[8].dp = buf;
17748 warpring_warp_dlg[8].dp3 = &warpring_warp_dlg[3].d1;
17749
17750 vector<DIALOG*> dlgs;
17751 dlgs.push_back(&warpring_warp_dlg[3]);
17752 dlgs.push_back(&warpring_warp_dlg[4]);
17753 warpring_warp_dlg[8].dp2 = &dlgs;
17754
17755 dmap_list_size=MAXDMAPS;
17756 dmap_list_zero=true;
17757
17758 large_dialog(warpring_warp_dlg);
17759
17760 int32_t ret=do_zqdialog(warpring_warp_dlg,-1);
17761
17762 if(ret==5 || ret==6)
17763 {
17764 saved=false;
17765 QMisc.warp[ring].dmap[index] = warpring_warp_dlg[3].d1;
17766 QMisc.warp[ring].scr[index] = zc_xtoi(buf);
17767 }
17768
17769 if(ret==6)
17770 {
17771 Map.dowarp2(ring,index);
17772 refresh(rALL);
17773 }
17774 }
17775
17776 int32_t d_warplist_proc(int32_t msg,DIALOG *d,int32_t c)
17777 {
17778 if(msg==MSG_DRAW)
17779 {
17780 int32_t *xy = (int32_t*)(d->dp3);
17781 int32_t ring = curr_ring;
17782 int32_t dmap = QMisc.warp[ring].dmap[d->d1];
17783 float temp_scale = 1.5;
17784
17785 drawdmap(dmap);
17786
17787 if(xy[0]||xy[1])
17788 {
17789 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
17790 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
17791 int32_t w = 84;
17792 int32_t h = 52;
17793 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
17794 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
17795 }
17796
17797 if(xy[2]||xy[3])
17798 {
17799 textprintf_ex(screen,font,d->x+int32_t(xy[2]*temp_scale),d->y+int32_t(xy[3]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %d ",DMaps[dmap].map+1);
17800 }
17801
17802 if(xy[4]||xy[5])
17803 {
17804 textprintf_ex(screen,font,d->x+int32_t(xy[4]*temp_scale),d->y+int32_t(xy[5]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level:%2d ",DMaps[dmap].level);
17805 }
17806
17807 if(xy[6]||xy[7])
17808 {
17809 textprintf_ex(screen,font,d->x+int32_t(xy[6]*temp_scale),d->y+int32_t(xy[7]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Scr: 0x%02X ",QMisc.warp[ring].scr[d->d1]);
17810 }
17811 }
17812
17813 return jwin_list_proc(msg,d,c);
17814 }
17815
17816 int32_t d_wclist_proc(int32_t msg,DIALOG *d,int32_t c)
17817 {
17818 int32_t d1 = d->d1;
17819 int32_t ret = jwin_droplist_proc(msg,d,c);
17820 QMisc.warp[curr_ring].size=d->d1+3;
17821
17822 if(d->d1 != d1)
17823 return D_CLOSE;
17824
17825 return ret;
17826 }
17827
17828 const char *wclist(int32_t index, int32_t *list_size)
17829 {
17830 static char buf[2];
17831
17832 if(index>=0)
17833 {
17834 if(index>6)
17835 index=6;
17836
17837 sprintf(buf,"%d",index+3);
17838 return buf;
17839 }
17840
17841 *list_size=7;
17842 return NULL;
17843 }
17844
17845 //int32_t warpringdmapxy[8] = {160,116,160,90,160,102,160,154};
17846 int32_t warpringdmapxy[8] = {80,26,80,0,80,12,80,78};
17847
17848 9 static ListData number_list(numberlist, &font);
17849 9 static ListData wc_list(wclist, &font);
17850
17851 static DIALOG warpring_dlg[] =
17852 {
17853 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17854 9 { jwin_win_proc, 0, 0, 193, 166, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17855 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17856 9 { jwin_text_proc, 16, 33, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Count:", NULL, NULL },
17857 9 { d_wclist_proc, 72, 29, 48, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &wc_list, NULL, NULL },
17858 // 4
17859 9 { d_warplist_proc, 16, 50, 65, 71, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &number_list, NULL, warpringdmapxy },
17860 9 { jwin_button_proc, 26, 140, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
17861 9 { jwin_button_proc, 106, 140, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
17862 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
17863 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17864 };
17865
17866 int32_t select_warp()
17867 {
17868 QMisc.warp[curr_ring].size = vbound(QMisc.warp[curr_ring].size,3,9);
17869 number_list_zero = false;
17870
17871 int32_t ret=4;
17872
17873 large_dialog(warpring_dlg);
17874
17875 do
17876 {
17877 number_list_size = QMisc.warp[curr_ring].size;
17878 warpring_dlg[3].d1 = QMisc.warp[curr_ring].size-3;
17879 ret = do_zqdialog(warpring_dlg,ret);
17880 }
17881 while(ret==3);
17882
17883 if(ret==6 || ret==0)
17884 {
17885 return -1;
17886 }
17887
17888 return warpring_dlg[4].d1;
17889 }
17890
17891 void EditWarpRing(int32_t ring)
17892 {
17893 char buf[40];
17894 sprintf(buf,"Ring %d Warps",ring);
17895 warpring_dlg[0].dp = buf;
17896 warpring_dlg[0].dp2 = get_zc_font(font_lfont);
17897 curr_ring = ring;
17898
17899 int32_t index = select_warp();
17900
17901 while(index!=-1)
17902 {
17903 EditWarpRingScr(ring,index);
17904 index = select_warp();
17905 }
17906 }
17907
17908 int32_t onWarpRings()
17909 {
17910 number_list_size = 9;
17911 number_list_zero = true;
17912
17913 int32_t index = select_data("Warp Rings",0,numberlist,"Edit","Done",get_zc_font(font_lfont));
17914
17915 while(index!=-1)
17916 {
17917 EditWarpRing(index);
17918 number_list_size = 9;
17919 number_list_zero = true;
17920 index = select_data("Warp Rings",index,numberlist,"Edit","Done",get_zc_font(font_lfont));
17921 }
17922
17923 return D_O_K;
17924 }
17925
17926
17927 const char *pattern_list(int32_t index, int32_t *list_size)
17928 {
17929
17930 if(index<0)
17931 {
17932 *list_size = MAXPATTERNS;
17933 return NULL;
17934 }
17935
17936 return pattern_string[index];
17937 }
17938
17939 9 static ListData pattern_dlg_list(pattern_list, &font);
17940
17941 static DIALOG pattern_dlg[] =
17942 {
17943 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17944 9 { jwin_win_proc, 72, 56, 176+1, 164+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Enemy Pattern", NULL, NULL },
17945 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17946 9 { jwin_list_proc, 80, 124, 160+1, 58, jwin_pal[jcTEXTFG],jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &pattern_dlg_list, NULL, NULL },
17947 // 3
17948 9 { jwin_button_proc, 90, 190, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
17949 9 { jwin_button_proc, 170, 190, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17950 9 { jwin_text_proc, 90, 78, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Classic: pseudorandom locations near", NULL, NULL },
17951 9 { jwin_text_proc, 90, 88, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "the middle of the screen.", NULL, NULL },
17952 9 { jwin_text_proc, 90, 102, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Random: any available location", NULL, NULL },
17953 9 { jwin_text_proc, 90, 112, 61, 10, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "at a sufficient distance from the Player.", NULL, NULL },
17954 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17955 };
17956
17957 int32_t onPattern()
17958 {
17959 byte p=Map.CurrScr()->pattern;
17960 pattern_dlg[0].dp2 = get_zc_font(font_lfont);
17961 pattern_dlg[2].d1 = p;
17962
17963 large_dialog(pattern_dlg);
17964
17965 if(do_zqdialog(pattern_dlg,2) < 4)
17966 {
17967 saved=false;
17968 Map.CurrScr()->pattern = pattern_dlg[2].d1;
17969 }
17970
17971 refresh(rMENU);
17972 return D_O_K;
17973 }
17974
17975 int32_t onEnemyFlags()
17976 {
17977 call_screendata_dialog(3);
17978 return D_O_K;
17979 }
17980
17981 const char *enemy_viewer(int32_t index, int32_t *list_size)
17982 {
17983 if(index<0)
17984 {
17985 *list_size=10;
17986
17987 return NULL;
17988 }
17989
17990 int32_t guy=Map.CurrScr()->enemy[index];
17991
17992 if (guy == 0) return "(None)";
17993 return guy>=eSTART ? guy_string[guy] : (char *) "(Guy - Do Not Use!)";
17994 }
17995
17996 enemy_struct bie[eMAXGUYS];
17997 enemy_struct ce[100];
17998 int32_t enemy_type=0,bie_cnt=-1,ce_cnt;
17999
18000 enemy_struct big[zqMAXGUYS];
18001 enemy_struct cg[100];
18002 int32_t guy_type=0,big_cnt=-1,cg_cnt;
18003
18004 //Uses old_max_guys[] in zq_misc.cpp to define what are visible if bool hide is set true. -Z
18005 void build_bie_list(bool hide)
18006 {
18007 bie[0].s = (char *)"(None)";
18008 bie[0].i = 0;
18009 bie_cnt=1;
18010
18011 for(int32_t i=1; i<eMAXGUYS; i++)
18012 {
18013 if (i < eSTART) continue; // ignore guys - enemies only!
18014
18015 if(i >= OLDMAXGUYS || old_guy_string[i][strlen(old_guy_string[i])-1]!=' ' || !hide)
18016 {
18017 bie[bie_cnt].s = (char *)guy_string[i];
18018 bie[bie_cnt].i = i;
18019 ++bie_cnt;
18020 }
18021 }
18022
18023 for(int32_t i=1; i<bie_cnt-1; i++) //Start at 1 so '(None)' isn't alphabetized!
18024 {
18025 for(int32_t j=i+1; j<bie_cnt; j++)
18026 {
18027 if(strcmp(bie[i].s,bie[j].s)>0)
18028 {
18029 zc_swap(bie[i],bie[j]);
18030 }
18031 }
18032 }
18033 }
18034
18035 void build_big_list(bool hide)
18036 {
18037 //big[0].s = (char *)"(None)";
18038 //big[0].i = 0;
18039 //big_cnt=1;
18040 big_cnt=0;
18041 for(int32_t i=0; i<gDUMMY1; i++)
18042 {
18043 if(moduledata.guy_type_names[i][0]!=' ' || !hide)
18044 {
18045 big[big_cnt].s = (char *)moduledata.guy_type_names[i];
18046 big[big_cnt].i = i;
18047 ++big_cnt;
18048 }
18049 }
18050
18051 for(int32_t i=1; i<big_cnt-1; i++) //start at 1, so that the none value is not alphabetized.
18052 {
18053 for(int32_t j=i+1; j<big_cnt; j++)
18054 {
18055 if(strcmp(big[i].s,big[j].s)>0)
18056 {
18057 zc_swap(big[i],big[j]);
18058 }
18059 }
18060 }
18061 }
18062
18063 const char *enemylist(int32_t index, int32_t *list_size)
18064 {
18065 if(index<0)
18066 {
18067 *list_size = enemy_type ? ce_cnt : bie_cnt;
18068 return NULL;
18069 }
18070
18071 return enemy_type ? ce[index].s : bie[index].s;
18072 }
18073
18074 const char *guylist(int32_t index, int32_t *list_size)
18075 {
18076 if(index<0)
18077 {
18078 *list_size = guy_type ? cg_cnt : big_cnt;
18079 return NULL;
18080 }
18081
18082 return guy_type ? cg[index].s : big[index].s;
18083 }
18084
18085 void elist_rclick_func(int32_t index, int32_t x, int32_t y);
18086 void paste_enemy(int32_t index = -1);
18087 void copy_enemy(int32_t index = -1);
18088 void save_enemy(int32_t index = -1);
18089 void load_enemy(int32_t index = -1);
18090 DIALOG elist_dlg[] =
18091 {
18092 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18093 9 { jwin_win_proc, 50, 40, 288, 175, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18094 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18095 9 { d_enelist_proc, 62, 68, 188, 98, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18096 9 { jwin_button_proc, 90, 160+20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18097 9 { jwin_button_proc, 170, 160+20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
18098 9 { jwin_button_proc, 220, 160+20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18099 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18100 };
18101
18102 static DIALOG glist_dlg[] =
18103 {
18104 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18105 9 { jwin_win_proc, 50, 40, 220, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18106 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18107 9 { jwin_abclist_proc, 62, 68, 196, 88, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
18108 9 { jwin_button_proc, 70, 160, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
18109 9 { jwin_button_proc, 190, 160, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18110 9 { jwin_button_proc, 130, 160, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
18111 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18112 };
18113
18114 int32_t efrontfacingtile(int32_t id)
18115 {
18116 int32_t anim = get_qr(qr_NEWENEMYTILES)?guysbuf[id].e_anim:guysbuf[id].anim;
18117 int32_t usetile = 0;
18118
18119 switch(anim)
18120 {
18121
18122 case aNONE: break;
18123 case aAQUA:
18124 if(!(get_qr(qr_NEWENEMYTILES) && guysbuf[id].attributes[0]))
18125 break;
18126
18127 case aWALLM:
18128 case aGHOMA:
18129 usetile=1;
18130 break;
18131
18132 //Fallthrough
18133 case a2FRM4DIR:
18134 case aWALK:
18135 usetile=2;
18136 break;
18137
18138 case aLEV:
18139 case a3FRM4DIR:
18140 usetile=3;
18141 break;
18142
18143 case aLANM:
18144 usetile = !(get_qr(qr_NEWENEMYTILES))?0:4;
18145 break;
18146
18147 case aNEWDONGO:
18148 case a4FRM8EYE:
18149 case aNEWWIZZ:
18150 case aARMOS4:
18151 case aNEWTEK:
18152 case aNEWWALLM:
18153 case a4FRM4DIRF:
18154 case a4FRM4DIR:
18155 case a4FRM8DIRF:
18156 case a4FRMPOS8DIR:
18157 case a4FRMPOS8DIRF:
18158 case a4FRMPOS4DIR:
18159 case a4FRMPOS4DIRF:
18160 usetile=4;
18161 break;
18162
18163 case aDONGO:
18164 usetile=6;
18165 break;
18166
18167 case aDONGOBS:
18168 usetile=24;
18169 break;
18170
18171 case aNEWLEV:
18172 usetile=40;
18173 break;
18174
18175 case aNEWZORA:
18176 if(guysbuf[id].family==eeZORA)
18177 usetile=44;
18178
18179 break;
18180
18181 case aGLEEOK:
18182 if(!get_qr(qr_NEWENEMYTILES))
18183 usetile = (guysbuf[id].s_tile - guysbuf[id].tile)+1;
18184 else
18185 usetile = (guysbuf[id].attributes[7]);
18186
18187 break;
18188 }
18189
18190 return zc_max(get_qr(qr_NEWENEMYTILES) ? -guysbuf[id].e_tile
18191 : -guysbuf[id].tile, usetile);
18192 }
18193
18194 9 static ListData enemy_dlg_list(enemy_viewer, &font);
18195
18196 int32_t enelist_proc(int32_t msg,DIALOG *d,int32_t c,bool use_abc_list)
18197 {
18198 FONT* oldfont = font;
18199 bool is_screen_select = d->dp == &enemy_dlg_list;
18200 int32_t ret;
18201
18202 if(!is_screen_select && msg == MSG_XCHAR)
18203 {
18204 if(key_shifts & KB_CTRL_FLAG) //CTRL overrides the lister search function
18205 {
18206 int32_t ret = D_USED_CHAR;
18207 switch(c>>8)
18208 {
18209 case KEY_V:
18210 paste_enemy();
18211 break;
18212 case KEY_C:
18213 copy_enemy();
18214 break;
18215 case KEY_S:
18216 save_enemy();
18217 break;
18218 case KEY_L:
18219 load_enemy();
18220 break;
18221 default: ret = 0;
18222 }
18223 if(ret) return ret;
18224 }
18225 }
18226
18227 if(use_abc_list)
18228 ret= jwin_abclist_proc(msg,d,c);
18229 else
18230 ret= jwin_list_proc(msg,d,c);
18231
18232 if(msg==MSG_DRAW||msg==MSG_CHAR)
18233 {
18234 int32_t id;
18235
18236 // Conveniently hacking the Select Enemy and Screen Enemy dialogs together -L
18237 if(d->dp == &enemy_dlg_list)
18238 {
18239 id = Map.CurrScr()->enemy[d->d1];
18240 }
18241 else
18242 {
18243 id = bie[d->d1].i;
18244 }
18245
18246 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile
18247 : guysbuf[id].tile;
18248 int32_t cset = guysbuf[id].cset;
18249 int32_t x = d->x + int32_t(195 * 1.5);
18250 int32_t y = d->y + 3;
18251 int32_t w = 36;
18252 int32_t h = 36;
18253
18254 BITMAP *buf = create_bitmap_ex(8,20,20);
18255 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
18256
18257 if(buf && bigbmp)
18258 {
18259 clear_bitmap(buf);
18260
18261 if(tile)
18262 overtile16(buf, tile+efrontfacingtile(id),2,2,cset,0);
18263
18264 stretch_blit(buf, bigbmp, 2,2, 17, 17, 2, 2,w-2, h-2);
18265 destroy_bitmap(buf);
18266 jwin_draw_frame(bigbmp,0,0,w,h,FR_DEEP);
18267 blit(bigbmp,screen,0,0,x,y,w,h);
18268 destroy_bitmap(bigbmp);
18269 }
18270
18271 font = get_zc_font(font_lfont_l);
18272 int fh = text_height(font);
18273 rectfill(screen,x,y+40,x+64,y+40+(10*fh),jwin_pal[jcBOX]);
18274 textprintf_ex(screen,font,x,y+40+(0*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"#%d",id);
18275
18276 textprintf_ex(screen,font,x,y+40+(1*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile: %d",guysbuf[id].tile);
18277
18278 textprintf_ex(screen,font,x,y+40+(2*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"sTil: %d",guysbuf[id].s_tile);
18279 textprintf_ex(screen,font,x,y+40+(3*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"eTil: %d",guysbuf[id].e_tile);
18280
18281 textprintf_ex(screen,font,x,y+40+(4*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"HP: %d",guysbuf[id].hp);
18282 textprintf_ex(screen,font,x,y+40+(5*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Dmg: %d",guysbuf[id].dp);
18283
18284 textprintf_ex(screen,font,x,y+40+(6*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Fam: %d",guysbuf[id].family);
18285 textprintf_ex(screen,font,x,y+40+(7*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Drop: %d",guysbuf[id].item_set);
18286 textprintf_ex(screen,font,x,y+40+(8*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Script: %d",guysbuf[id].script);
18287 textprintf_ex(screen,font,x,y+40+(9*fh),jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"WScript: %d",guysbuf[id].weaponscript);
18288 }
18289 font = oldfont;
18290 return ret;
18291 }
18292
18293 int32_t select_enemy(const char *prompt,int32_t enemy,bool hide,bool is_editor,int32_t &exit_status)
18294 {
18295 //if(bie_cnt==-1)
18296 {
18297 build_bie_list(hide);
18298 }
18299 int32_t index=0;
18300
18301 for(int32_t j=0; j<bie_cnt; j++)
18302 {
18303 if(bie[j].i == enemy)
18304 {
18305 index=j;
18306 }
18307 }
18308
18309 elist_dlg[0].dp=(void *)prompt;
18310 elist_dlg[0].dp2=get_zc_font(font_lfont);
18311 elist_dlg[2].d1=index;
18312 ListData enemy_list(enemylist, &font);
18313 elist_dlg[2].dp=(void *) &enemy_list;
18314
18315 large_dialog(elist_dlg);
18316
18317 if(is_editor)
18318 {
18319 elist_dlg[2].dp3 = (void *)&elist_rclick_func;
18320 elist_dlg[2].flags|=(D_USER<<1);
18321 elist_dlg[3].dp = (void *)"Edit";
18322 elist_dlg[4].dp = (void *)"Done";
18323 elist_dlg[3].x = 285;
18324 elist_dlg[4].x = 405;
18325 elist_dlg[5].flags |= D_HIDDEN;
18326 }
18327 else
18328 {
18329 elist_dlg[2].dp3 = NULL;
18330 elist_dlg[2].flags&=~(D_USER<<1);
18331 elist_dlg[3].dp = (void *)"OK";
18332 elist_dlg[4].dp = (void *)"Cancel";
18333 elist_dlg[3].x = 240;
18334 elist_dlg[4].x = 350;
18335 elist_dlg[5].flags &= ~D_HIDDEN;
18336 }
18337
18338 exit_status=do_zqdialog(elist_dlg,2);
18339
18340 if(exit_status==0||exit_status==4)
18341 {
18342 return -1;
18343 }
18344
18345 index = elist_dlg[2].d1;
18346 return bie[index].i;
18347 }
18348
18349 uint8_t check[2] = { (uint8_t)'\x81',0 };
18350
18351 static DIALOG enemy_dlg[] =
18352 {
18353 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18354 9 { jwin_win_proc, 0, 0, 256, 190+10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Enemies", NULL, NULL },
18355 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18356 9 { d_enelistnoabc_proc, 14, 24, 188, 97, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enemy_dlg_list, NULL, NULL },
18357 9 { jwin_button_proc, 12, 130+10, 109, 21, vc(14), vc(1), 'e', D_EXIT, 0, 0, (void *) "Paste &Enemies", NULL, NULL },
18358 9 { d_dummy_proc, 210, 24, 20, 20, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
18359 9 { jwin_button_proc, 127, 130+10, 42, 21, vc(14), vc(1), 'f', D_EXIT, 0, 0, (void *) "&Flags", NULL, NULL },
18360 9 { jwin_button_proc, 175, 130+10, 53, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Pattern", NULL, NULL },
18361 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'c', 0, 0, 0, (void *) close_dlg, NULL, NULL },
18362 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'v', 0, 0, 0, (void *) close_dlg, NULL, NULL },
18363 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, 0, (void *) close_dlg, NULL, NULL },
18364 // 10
18365 9 { jwin_button_proc, 50, 156+10, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18366 9 { jwin_button_proc, 130, 156+10, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18367 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, (void *) close_dlg, NULL, NULL },
18368 9 { jwin_text_proc, 4, 208, 8, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) check, NULL, NULL },
18369 9 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
18370 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18371 };
18372
18373 int32_t onEnemies()
18374 {
18375 word oldenemy[10];
18376 memcpy(oldenemy,Map.CurrScr()->enemy,10*sizeof(word));
18377 restore_mouse();
18378 char buf[26] = " ";
18379 int32_t ret;
18380 int32_t copy=-1;
18381
18382 build_bie_list(true);
18383
18384 enemy_dlg[0].dp2=get_zc_font(font_lfont);
18385
18386 if(Map.CanPaste())
18387 {
18388 enemy_dlg[3].flags=D_EXIT;
18389 sprintf(buf,"Past&e (from %d:%02X)",(Map.CopyScr()>>8)+1,Map.CopyScr()&255);
18390 }
18391 else
18392 {
18393 enemy_dlg[3].flags=D_DISABLED;
18394 sprintf(buf,"Past&e from screen");
18395 }
18396
18397 enemy_dlg[3].dp=buf;
18398 enemy_dlg[2].d1=0;
18399
18400 do
18401 {
18402 if(copy==-1)
18403 {
18404 enemy_dlg[13].y=zq_screen_h;
18405 }
18406 else
18407 {
18408 enemy_dlg[13].y=(int32_t)((copy<<3)*1.6)+enemy_dlg[2].y+4;
18409 }
18410
18411 large_dialog(enemy_dlg);
18412 // Fix d_enelist_proc
18413 enemy_dlg[2].dp2 = 0;
18414 ((ListData *)enemy_dlg[2].dp)->font = &a4fonts[font_lfont_l];
18415
18416 ret = do_zqdialog(enemy_dlg,2);
18417
18418 switch(ret)
18419 {
18420 case 2:
18421 {
18422 int32_t exit_status;
18423 int32_t i = enemy_dlg[2].d1;
18424 popup_zqdialog_start();
18425 do
18426 {
18427 int32_t enemy = Map.CurrScr()->enemy[i];
18428 enemy = select_enemy("Select Enemy",enemy,true,false,exit_status);
18429
18430 if(enemy>=0)
18431 {
18432 if(exit_status==5 && enemy > 0)
18433 {
18434 edit_enemydata(enemy);
18435 }
18436 else
18437 {
18438 saved=false;
18439 Map.CurrScr()->enemy[i] = enemy;
18440 }
18441 }
18442 }
18443 while(exit_status==5);
18444 popup_zqdialog_end();
18445 }
18446 break;
18447
18448 case 3:
18449 saved=false;
18450 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies);
18451 break;
18452
18453 case 5:
18454 onEnemyFlags();
18455 break;
18456
18457 case 6:
18458 onPattern();
18459 break;
18460
18461 case 7:
18462 copy = enemy_dlg[2].d1;
18463 break;
18464
18465 case 8:
18466 saved=false;
18467
18468 if(copy>=0)
18469 {
18470 Map.CurrScr()->enemy[enemy_dlg[2].d1] = Map.CurrScr()->enemy[copy];
18471 }
18472
18473 break;
18474
18475 case 9:
18476 saved=false;
18477 Map.CurrScr()->enemy[enemy_dlg[2].d1] = 0;
18478 break;
18479
18480 case 0:
18481 case 11: //cancel
18482 memcpy(Map.CurrScr()->enemy,oldenemy,10*sizeof(word));
18483 break;
18484
18485 case 10: //ok
18486 {
18487 bool end = false;
18488
18489 for(int32_t i=0; i<10; i++)
18490 {
18491 if(Map.CurrScr()->enemy[i]==0)
18492 end = true;
18493 else if(end)
18494 {
18495 if(jwin_alert("Inactive Enemies","Enemies won't appear if they're preceded"," by '(None)' in the list! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
18496 ret=-1;
18497
18498 break;
18499 }
18500 }
18501
18502 break;
18503 }
18504 }
18505 }
18506 while(ret<10&&ret!=0);
18507
18508 refresh(rALL);
18509 return D_O_K;
18510 }
18511
18512 char author[65],title[65],password[32];
18513
18514 int32_t d_showedit_proc(int32_t msg,DIALOG *d,int32_t c)
18515 {
18516 int32_t ret = jwin_edit_proc(msg,d,c);
18517
18518 if(msg==MSG_DRAW)
18519 {
18520 (d+1)->proc(MSG_DRAW,d+1,0);
18521 }
18522
18523 return ret;
18524 }
18525
18526 int32_t onHeader()
18527 {
18528 call_header_dlg();
18529 return D_O_K;
18530 }
18531
18532 void call_cheats_dlg();
18533 int32_t onCheats()
18534 {
18535 call_cheats_dlg();
18536 return D_O_K;
18537 }
18538
18539 bool do_x_button(BITMAP *dest, int32_t x, int32_t y)
18540 {
18541 bool over=false;
18542
18543 while(gui_mouse_b())
18544 {
18545 custom_vsync();
18546
18547 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
18548 {
18549 if(!over)
18550 {
18551 draw_x_button(dest, x, y, D_SELECTED);
18552 over=true;
18553 }
18554 }
18555 else
18556 {
18557 if(over)
18558 {
18559 draw_x_button(dest, x, y, 0);
18560 over=false;
18561 }
18562 }
18563 }
18564
18565 return over;
18566 }
18567
18568 bool do_question_button(BITMAP *dest, int32_t x, int32_t y)
18569 {
18570 bool over=false;
18571
18572 while(gui_mouse_b())
18573 {
18574 custom_vsync();
18575
18576 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
18577 {
18578 if(!over)
18579 {
18580 draw_question_button(dest, x, y, D_SELECTED);
18581 over=true;
18582 }
18583 }
18584 else
18585 {
18586 if(over)
18587 {
18588 draw_question_button(dest, x, y, 0);
18589 over=false;
18590 }
18591 }
18592 }
18593
18594 return over;
18595 }
18596
18597
18598 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
18599 {
18600 return D_O_K;
18601 }
18602
18603 int32_t d_maptile_proc(int32_t msg, DIALOG *d, int32_t)
18604 {
18605 switch(msg)
18606 {
18607 case MSG_CLICK:
18608 if(select_tile(d->d1,d->d2,1,d->fg,true, 0, true))
18609 return D_REDRAW;
18610
18611 case MSG_DRAW:
18612 {
18613 int32_t dw = d->w;
18614 int32_t dh = d->h;
18615
18616 if(d->dp2==(void*)1)
18617 {
18618 dw /= 2;
18619 dh /= 2;
18620 }
18621
18622 BITMAP *buf = create_bitmap_ex(8,dw,dh);
18623
18624 if(buf)
18625 {
18626 clear_bitmap(buf);
18627
18628 for(int32_t y=0; y<dh; y+=16)
18629 for(int32_t x=0; x<dw; x+=16)
18630 {
18631 if(d->d1)
18632 puttile16(buf,d->d1+(y>>4)*20+(x>>4),x,y,d->fg,0);
18633 }
18634
18635 if(d->dp2==(void*)1)
18636 stretch_blit(buf,screen,0,0,dw,dh,d->x-1,d->y-1,dw*2,dh*2);
18637 else
18638 blit(buf,screen,0,0,d->x,d->y,dw,dh);
18639
18640 destroy_bitmap(buf);
18641 }
18642 }
18643 }
18644
18645 return D_O_K;
18646 }
18647
18648 static int32_t last_combo=0;
18649 static int32_t last_cset=0;
18650
3/4
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 73719 times.
✓ Branch 3 taken 9 times.
73728 static combo_alias temp_aliases[MAXCOMBOALIASES];
18651
18652 static char comboa_str_buf[32];
18653
18654 int32_t d_comboalist_proc(int32_t msg,DIALOG *d,int32_t c)
18655 {
18656 int32_t d1 = d->d1;
18657 int32_t ret = jwin_droplist_proc(msg,d,c);
18658 comboa_cnt = d->d1;
18659
18660 if(d1!=d->d1)
18661 {
18662 set_comboaradio(temp_aliases[comboa_cnt].layermask);
18663 return D_REDRAW;
18664 }
18665
18666 return ret;
18667 }
18668
18669 const char *comboalist(int32_t index, int32_t *list_size)
18670 {
18671 if(index>=0)
18672 {
18673 bound(index,0,MAXCOMBOALIASES-1);
18674 sprintf(comboa_str_buf,"%d",index);
18675 return comboa_str_buf;
18676 }
18677
18678 *list_size=MAXCOMBOALIASES;
18679 return NULL;
18680 }
18681
18682 extern int32_t scheme[jcMAX];
18683
18684 int32_t d_comboa_proc(int32_t msg,DIALOG *d,int32_t c)
18685 {
18686 //these are here to bypass compiler warnings about unused arguments
18687 c=c;
18688
18689 combo_alias *combo;
18690 combo = &temp_aliases[comboa_cnt];
18691 int32_t position;
18692 int32_t cur_layer, temp_layer;
18693 int32_t lay_count=0;
18694 int32_t size = 2;
18695
18696 int32_t cx1=(gui_mouse_x()-d->x-(120-(combo->width*8)));
18697 int32_t cy1=(gui_mouse_y()-d->y-(80-(combo->height*8)));
18698 int32_t cx=cx1/(16*size);
18699 int32_t cy=cy1/(16*size);
18700
18701 int32_t co,cs;
18702
18703
18704 switch(msg)
18705 {
18706 case MSG_CLICK:
18707 if((cx>combo->width)||(cx1<0))
18708 return D_O_K;
18709
18710 if((cy>combo->height)||(cy1<0))
18711 return D_O_K;
18712
18713 for(int32_t j=0; j<layer_cnt; j++)
18714 {
18715 if(combo->layermask&(1<<j))
18716 lay_count++;
18717 }
18718
18719 position=(lay_count)*(combo->width+1)*(combo->height+1);
18720 position+=(cy*(combo->width+1))+cx;
18721
18722 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
18723 {
18724 combo->combos[position] = 0;
18725 combo->csets[position] = 0;
18726
18727 while(gui_mouse_b())
18728 {
18729 /* do nothing */
18730 rest(1);
18731 }
18732
18733 return D_REDRAW;
18734 }
18735
18736 co=combo->combos[position];
18737 cs=combo->csets[position];
18738
18739 if((co==0)||(key[KEY_ZC_LCONTROL]))
18740 {
18741 co=last_combo;
18742 cs=last_cset;
18743 }
18744
18745 if((select_combo_2(co,cs)))
18746 {
18747 last_combo = co;
18748 last_cset = cs;
18749
18750 combo->combos[position]=co;
18751 combo->csets[position]=cs;
18752 }
18753
18754 return D_REDRAW;
18755 break;
18756
18757 case MSG_DRAW:
18758 BITMAP *buf = create_bitmap_ex(8,d->w,d->h);
18759
18760 if(buf)
18761 {
18762 clear_bitmap(buf);
18763
18764 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
18765 {
18766 int32_t k=0;
18767 cur_layer=0;
18768 temp_layer=combo->layermask;
18769
18770 while((temp_layer!=0)&&(k<z))
18771 {
18772 if(temp_layer&1)
18773 {
18774 k++;
18775 }
18776
18777 cur_layer++;
18778 temp_layer = temp_layer>>1;
18779 }
18780
18781 for(int32_t y=0; (y<d->h)&&((y/16)<=combo->height); y+=16)
18782 {
18783 for(int32_t x=0; (x<d->w)&&((x/16)<=combo->width); x+=16)
18784 {
18785 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y/16)*(combo->width+1))+(x/16));
18786
18787 if(combo->combos[cpos])
18788 {
18789 if(!((d-1)->flags&D_SELECTED)||(cur_layer==layer_cnt))
18790 {
18791 if(z==0)
18792 {
18793 puttile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18794 }
18795 else
18796 {
18797 overtile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18798 }
18799 }
18800 }
18801 }
18802 }
18803 }
18804
18805 rectfill(screen, d->x-2,d->y-2,d->x+256+2,d->y+176+2,jwin_pal[jcBOX]);
18806 int32_t dx = 120-(combo->width*8)+d->x;
18807 int32_t dy = 80-(combo->height*8)+d->y;
18808 stretch_blit(buf,screen,0,0,(combo->width+1)*16,(combo->height+1)*16,dx,dy,(combo->width+1)*16*size,(combo->height+1)*16*size);
18809 //blit(buf,screen,0,0,120-(combo->width*8)+d->x,80-(combo->height*8)+d->y,(combo->width+1)*16,(combo->height+1)*16);
18810 (d-11)->w = (combo->width+1)*16*size+2;
18811 (d-11)->h = (combo->height+1)*16*size+2;
18812 (d-11)->x = 120-(combo->width*8)+4*size+2+(d-14)->x;
18813 (d-11)->y = 80-(combo->height*8)+25*size+2+(d-14)->y;
18814 object_message((d-11),MSG_DRAW,0);
18815
18816 destroy_bitmap(buf);
18817 }
18818
18819 break;
18820 }
18821
18822 return D_O_K;
18823 }
18824
18825 void draw_combo_alias_thumbnail(BITMAP *dest, combo_alias const* combo, int32_t x, int32_t y, int32_t size)
18826 {
18827 if(!combo->combo)
18828 {
18829 int32_t cur_layer, temp_layer;
18830
18831 int32_t cw=combo->width+1;
18832 int32_t ch=combo->height+1;
18833 int32_t dw=cw<<4;
18834 int32_t dh=ch<<4;
18835 int32_t sw=16, sh=16, sx=0, sy=0;
18836
18837 if(cw<ch)
18838 {
18839 sw=((cw<<4)/ch);
18840 sx=((16-sw)>>1);
18841 }
18842 else
18843 {
18844 sh=((ch<<4)/cw);
18845 sy=((16-sh)>>1);
18846 }
18847
18848 BITMAP *buf = create_bitmap_ex(8,dw,dh);
18849 BITMAP *buf2 = create_bitmap_ex(8, 16*size, 16*size);
18850 clear_bitmap(buf);
18851 clear_bitmap(buf2);
18852
18853 if(buf&&(combo->width>0||combo->height>0||combo->combos[0]>0))
18854 {
18855 clear_bitmap(buf);
18856
18857 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
18858 {
18859 int32_t k=0;
18860 cur_layer=0;
18861 temp_layer=combo->layermask;
18862
18863 while((temp_layer!=0)&&(k<z))
18864 {
18865 if(temp_layer&1)
18866 {
18867 k++;
18868 }
18869
18870 cur_layer++;
18871 temp_layer = temp_layer>>1;
18872 }
18873
18874 for(int32_t y2=0; (y2<dh)&&((y2>>4)<=combo->height); y2+=16)
18875 {
18876 for(int32_t x2=0; (x2<dw)&&((x2>>4)<=combo->width); x2+=16)
18877 {
18878 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y2/16)*(combo->width+1))+(x2/16));
18879
18880 if(combo->combos[cpos])
18881 {
18882 if(z==0)
18883 {
18884 puttile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18885 }
18886 else
18887 {
18888 overtile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
18889 }
18890 }
18891 }
18892 }
18893 }
18894
18895 stretch_blit(buf, buf2, 0, 0, (cw*16), (ch*16), sx*size, sy*size, sw*size, sh*size);
18896 blit(buf2, dest, 0, 0, x, y, 16*size, 16*size);
18897 }
18898 else
18899 {
18900 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
18901 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
18902 }
18903
18904 if(buf)
18905 destroy_bitmap(buf);
18906
18907 if(buf2)
18908 destroy_bitmap(buf2);
18909 }
18910 else
18911 {
18912 if(combobuf[combo->combo].tile>0)
18913 {
18914 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
18915 put_combo(dest, x, y, combo->combo, combo->cset, 0, 0, size);
18916 }
18917 else
18918 {
18919 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
18920 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
18921 }
18922 }
18923 }
18924
18925 int32_t d_comboat_proc(int32_t msg,DIALOG *d,int32_t)
18926 {
18927 switch(msg)
18928 {
18929 case MSG_CLICK:
18930 {
18931 int32_t c2;
18932 int32_t cs;
18933 c2=temp_aliases[comboa_cnt].combo;
18934 cs=temp_aliases[comboa_cnt].cset;
18935
18936 if(gui_mouse_b()&2) //right mouse button
18937 {
18938 if(c2==0&&cs==0&&!(gui_mouse_b()&1))
18939 {
18940 return D_O_K;
18941 }
18942
18943 temp_aliases[comboa_cnt].combo=0;
18944 temp_aliases[comboa_cnt].cset=0;
18945 }
18946
18947 if(gui_mouse_b()&1) //left mouse button
18948 {
18949 if(select_combo_2(c2, cs))
18950 {
18951 temp_aliases[comboa_cnt].combo=c2;
18952 temp_aliases[comboa_cnt].cset=cs;
18953 }
18954
18955 return D_REDRAW;
18956 }
18957 else
18958 {
18959 return D_REDRAWME;
18960 }
18961 }
18962 break;
18963
18964 case MSG_DRAW:
18965 draw_combo_alias_thumbnail(screen, &temp_aliases[comboa_cnt], d->x-1, d->y-1,2);
18966 break;
18967
18968 default:
18969 break;
18970 }
18971
18972 return D_O_K;
18973 }
18974
18975 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c);
18976
18977 static DIALOG orgcomboa_dlg[] =
18978 {
18979 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18980 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Organize Combo Aliases", NULL, NULL },
18981 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18982 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18983
18984 { jwin_radio_proc, 10, 40, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Copy", NULL, NULL },
18985 { jwin_text_proc, 10, 50, 33, 9, 0, 0, 0, 0, 0, 0, (void *) "", NULL, NULL },
18986 // { jwin_radio_proc, 10, 50, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Move", NULL, NULL },
18987 { jwin_radio_proc, 10, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Swap", NULL, NULL },
18988 /* 6 */ { jwin_edit_proc, 110, 35, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
18989 { jwin_edit_proc, 110, 55, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
18990 { jwin_text_proc, 60, 40, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Source", NULL, NULL },
18991 { jwin_text_proc, 60, 60, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Dest", NULL, NULL},
18992 { jwin_radio_proc, 10, 80, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Insert new (before source)", NULL, NULL },
18993 { jwin_radio_proc, 10, 100, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Delete source", NULL, NULL },
18994 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18995 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18996 };
18997
18998 static DIALOG newcomboa_dlg[] =
18999 {
19000 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
19001 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Properties", NULL, NULL },
19002 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
19003 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19004 { jwin_text_proc, 24, 34, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Width", NULL, NULL },
19005 { jwin_text_proc, 24, 52, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Height", NULL, NULL },
19006 { jwin_text_proc, 24, 70, 100, 8, 0, 0, 0, 0, 0, 0, (void *) "Layers to Draw On:", NULL, NULL },
19007 { jwin_edit_proc, 104, 30, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19008 { jwin_edit_proc, 122, 48, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19009 { jwin_check_proc, 24, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "1", NULL, NULL },
19010 { jwin_check_proc, 50, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "2", NULL, NULL },
19011 { jwin_check_proc, 76, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "3", NULL, NULL },
19012 { jwin_check_proc, 102, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "4", NULL, NULL },
19013 { jwin_check_proc, 128, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "5", NULL, NULL },
19014 { jwin_check_proc, 154, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "6", NULL, NULL },
19015
19016
19017 // { jwin_text_proc, 24, 106, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Copy to :", NULL, NULL },
19018 //15
19019 // { jwin_edit_proc, 100, 100, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
19020 // { jwin_check_proc, 84, 106, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "", NULL, NULL },
19021
19022 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19023 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19024 };
19025
19026 bool swapComboAlias(int32_t source, int32_t dest)
19027 {
19028 if(source==dest)
19029 return false;
19030 zc_swap(temp_aliases[source],temp_aliases[dest]);
19031 return true;
19032 }
19033
19034
19035 bool copyComboAlias(int32_t source, int32_t dest)
19036 {
19037 if(source == dest)
19038 return false;
19039 temp_aliases[dest] = temp_aliases[source];
19040 return true;
19041 }
19042
19043 int32_t getcurrentcomboalias();
19044
19045 int32_t onOrgComboAliases()
19046 {
19047 char cSrc[8];
19048 char cDest[8];
19049 sprintf(cSrc,"%d", getcurrentcomboalias());
19050 strcpy(cDest,cSrc);
19051 int32_t iSrc = 0;
19052 int32_t iDest = 0;
19053
19054 //sprintf(cSrc,"0");
19055 //sprintf(cDest,"0");
19056 orgcomboa_dlg[0].dp2=get_zc_font(font_lfont);
19057 orgcomboa_dlg[6].dp= cSrc;
19058 orgcomboa_dlg[7].dp= cDest;
19059 int32_t ret = 1;
19060 large_dialog(orgcomboa_dlg);
19061 do
19062 {
19063 iSrc = atoi((char*)orgcomboa_dlg[6].dp);
19064 iDest = atoi((char*)orgcomboa_dlg[7].dp);
19065 ret = do_zqdialog(orgcomboa_dlg,-1);
19066
19067 if(ret!=1) return ret;
19068
19069 if((atoi((char*) orgcomboa_dlg[6].dp))<0 || (atoi((char*) orgcomboa_dlg[6].dp)) > MAXCOMBOALIASES-1)
19070 {
19071 char buf[100];
19072 snprintf(buf, 100, "Invalid source (range 0-%d)", MAXCOMBOALIASES-1);
19073 buf[99]='\0';
19074 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19075 ret = 1;
19076 }
19077
19078 // 10,11=ins, del
19079 if(orgcomboa_dlg[10].flags & D_SELECTED) //insert
19080 {
19081 for(int32_t j=MAXCOMBOALIASES-1; j>(atoi((char*) orgcomboa_dlg[6].dp)); --j)
19082 copyComboAlias(j-1,j);
19083 ret = -1;
19084 }
19085
19086 if(orgcomboa_dlg[11].flags & D_SELECTED) //delete
19087 {
19088 for(int32_t j=(atoi((char*) orgcomboa_dlg[6].dp)); j<MAXCOMBOALIASES-1; ++j)
19089 copyComboAlias(j+1,j);
19090 ret = -1;
19091 }
19092
19093 if((atoi((char*) orgcomboa_dlg[6].dp)) == (atoi((char*) orgcomboa_dlg[7].dp)))
19094 {
19095 jwin_alert("Error","Source and dest can't be the same.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19096 ret = 1;
19097 }
19098
19099 if((atoi((char*) orgcomboa_dlg[7].dp)) < 0 || (atoi((char*) orgcomboa_dlg[7].dp)) > MAXCOMBOALIASES-1)
19100 {
19101 char buf[100];
19102 snprintf(buf, 100, "Invalid dest (range 0-%d)", MAXCOMBOALIASES-1);
19103 buf[99]='\0';
19104
19105 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
19106 ret = 1;
19107 }
19108
19109 if(orgcomboa_dlg[3].flags & D_SELECTED) //copy
19110 {
19111 copyComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
19112 ret = -1;
19113 }
19114
19115 if(orgcomboa_dlg[5].flags & D_SELECTED) //swap
19116 {
19117 swapComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
19118 ret = -1;
19119 }
19120 }
19121 while(ret==1);
19122 return ret;
19123 }
19124
19125 int32_t onNewComboAlias()
19126 {
19127 combo_alias *combo;
19128 combo = &temp_aliases[comboa_cnt];
19129
19130 char cwidth[5];
19131 char cheight[5];
19132 // char cp[3];
19133
19134 word temp_combos[16*11*7];
19135 byte temp_csets[16*11*7];
19136 sprintf(cwidth, "%d", combo->width+1);
19137 sprintf(cheight, "%d", combo->height+1);
19138 int32_t old_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
19139 int32_t old_width=combo->width;
19140 int32_t old_height=combo->height;
19141 int32_t oldlayer=combo->layermask;
19142
19143 for(int32_t i=0; i<old_count; i++)
19144 {
19145 temp_csets[i] = combo->csets[i];
19146 temp_combos[i] = combo->combos[i];
19147 }
19148
19149 newcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
19150 newcomboa_dlg[6].dp = cwidth;
19151 newcomboa_dlg[7].dp = cheight;
19152 newcomboa_dlg[8].flags = (combo->layermask&1)? D_SELECTED : 0;
19153 newcomboa_dlg[9].flags = (combo->layermask&2)? D_SELECTED : 0;
19154 newcomboa_dlg[10].flags = (combo->layermask&4)? D_SELECTED : 0;
19155 newcomboa_dlg[11].flags = (combo->layermask&8)? D_SELECTED : 0;
19156 newcomboa_dlg[12].flags = (combo->layermask&16)? D_SELECTED : 0;
19157 newcomboa_dlg[13].flags = (combo->layermask&32)? D_SELECTED : 0;
19158
19159 large_dialog(newcomboa_dlg);
19160
19161 int32_t ret = do_zqdialog(newcomboa_dlg,-1);
19162
19163 if(ret==1)
19164 {
19165 combo->width = ((atoi(cwidth)-1)<16)?zc_max(0,(atoi(cwidth)-1)):15;
19166 combo->height = ((atoi(cheight)-1)<11)?zc_max(0,(atoi(cheight)-1)):10;
19167 combo->layermask=0;
19168 combo->layermask |= (newcomboa_dlg[8].flags&D_SELECTED)?1:0;
19169 combo->layermask |= (newcomboa_dlg[9].flags&D_SELECTED)?2:0;
19170 combo->layermask |= (newcomboa_dlg[10].flags&D_SELECTED)?4:0;
19171 combo->layermask |= (newcomboa_dlg[11].flags&D_SELECTED)?8:0;
19172 combo->layermask |= (newcomboa_dlg[12].flags&D_SELECTED)?16:0;
19173 combo->layermask |= (newcomboa_dlg[13].flags&D_SELECTED)?32:0;
19174
19175 int32_t new_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
19176
19177 combo->combos.clear();
19178 combo->csets.clear();
19179
19180 int32_t j=1;
19181 int32_t old_size=(old_width+1)*(old_height+1);
19182 int32_t new_start[7] =
19183 {
19184 0,
19185 ((combo->width+1)*(combo->height+1)*(1)),
19186 ((combo->width+1)*(combo->height+1)*(2)),
19187 ((combo->width+1)*(combo->height+1)*(3)),
19188 ((combo->width+1)*(combo->height+1)*(4)),
19189 ((combo->width+1)*(combo->height+1)*(5)),
19190 ((combo->width+1)*(combo->height+1)*(6))
19191 };
19192 int32_t new_layers[6] = {0,0,0,0,0,0};
19193 int32_t temp_layer = combo->layermask;
19194 int32_t temp_old = oldlayer;
19195 int32_t old_layers[6] = {0,0,0,0,0,0};
19196 int32_t k=1;
19197
19198 for(int32_t i=0; (i<6)&&(temp_layer!=0); j++,temp_layer>>=1,temp_old>>=1)
19199 {
19200 if(temp_layer&1)
19201 {
19202 new_layers[i] = j;
19203 //if(oldlayer&(1<<(j-1))) old_layers[i] = k++;
19204 i++;
19205 }
19206
19207 if(temp_old&1)
19208 {
19209 if(temp_layer&1)
19210 {
19211 old_layers[i-1] = k;
19212 }
19213
19214 k++;
19215 }
19216 }
19217
19218 for(int32_t i=0; i<new_count; i++)
19219 {
19220 if(i>=new_start[6])
19221 {
19222 //oldl=oldlayer>>(new_layers[5]-1);
19223 j=i-new_start[6];
19224
19225 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[5]-1))))
19226 {
19227 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
19228 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
19229 }
19230 else
19231 {
19232 combo->combos[i] = 0;
19233 combo->csets[i] = 0;
19234 }
19235 }
19236 else if(i>=new_start[5])
19237 {
19238 //oldl=oldlayer>>(new_layers[4]-1);
19239 j=i-new_start[5];
19240
19241 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[4]-1))))
19242 {
19243 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
19244 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
19245 }
19246 else
19247 {
19248 combo->combos[i] = 0;
19249 combo->csets[i] = 0;
19250 }
19251 }
19252 else if(i>=new_start[4])
19253 {
19254 //oldl=oldlayer>>(new_layers[3]-1);
19255 j=i-new_start[4];
19256
19257 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[3]-1))))
19258 {
19259 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
19260 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
19261 }
19262 else
19263 {
19264 combo->combos[i] = 0;
19265 combo->csets[i] = 0;
19266 }
19267 }
19268 else if(i>=new_start[3])
19269 {
19270 //oldl=oldlayer>>(new_layers[2]-1);
19271 j=i-new_start[3];
19272
19273 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[2]-1))))
19274 {
19275 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
19276 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
19277 }
19278 else
19279 {
19280 combo->combos[i] = 0;
19281 combo->csets[i] = 0;
19282 }
19283 }
19284 else if(i>=new_start[2])
19285 {
19286 //oldl=oldlayer>>(new_layers[1]-1);
19287 j=i-new_start[2];
19288
19289 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[1]-1))))
19290 {
19291 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
19292 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
19293 }
19294 else
19295 {
19296 combo->combos[i] = 0;
19297 combo->csets[i] = 0;
19298 }
19299 }
19300 else if(i>=new_start[1])
19301 {
19302 //oldl=oldlayer>>(new_layers[0]-1);
19303 j=i-new_start[1];
19304
19305 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[0]-1))))
19306 {
19307 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
19308 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
19309 }
19310 else
19311 {
19312 combo->combos[i] = 0;
19313 combo->csets[i] = 0;
19314 }
19315 }
19316 else if(i>=new_start[0])
19317 {
19318 if(((i/(combo->width+1))<=old_height)&&((i%(combo->width+1))<=old_width))
19319 {
19320 combo->combos[i] = temp_combos[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
19321 combo->csets[i] = temp_csets[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
19322 }
19323 else
19324 {
19325 combo->combos[i] = 0;
19326 combo->csets[i] = 0;
19327 }
19328 }
19329 }
19330
19331 set_comboaradio(combo->layermask);
19332 }
19333
19334 return ret;
19335 }
19336
19337 int32_t d_orgcomboa_proc(int32_t msg, DIALOG *d, int32_t c)
19338 {
19339 //these are here to bypass compiler warnings about unused arguments
19340 c=c;
19341
19342 int32_t down=0;
19343 int32_t selected=(d->flags&D_SELECTED)?1:0;
19344 int32_t last_draw;
19345
19346 switch(msg)
19347 {
19348
19349 case MSG_DRAW:
19350 {
19351 FONT *tfont=font;
19352 font=get_zc_font(font_lfont_l);
19353 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
19354 font=tfont;
19355 }
19356 break;
19357
19358 case MSG_WANTFOCUS:
19359 return D_WANTFOCUS;
19360
19361 case MSG_KEY:
19362 /* close dialog? */
19363 onOrgComboAliases();
19364 return D_REDRAW;
19365
19366 /* or just toggle */
19367 /*d->flags ^= D_SELECTED;
19368 object_message(d, MSG_DRAW, 0);
19369 break;*/
19370
19371 case MSG_CLICK:
19372 last_draw = 0;
19373
19374 /* track the mouse until it is released */
19375 while(gui_mouse_b())
19376 {
19377 down = mouse_in_rect(d->x, d->y, d->w, d->h);
19378
19379 /* redraw? */
19380 if(last_draw != down)
19381 {
19382 if(down != selected)
19383 d->flags |= D_SELECTED;
19384 else
19385 d->flags &= ~D_SELECTED;
19386
19387 object_message(d, MSG_DRAW, 0);
19388 last_draw = down;
19389 }
19390
19391 /* let other objects continue to animate */
19392 broadcast_dialog_message(MSG_IDLE, 0);
19393 }
19394
19395 /* redraw in normal state */
19396 if(down)
19397 {
19398 if(d->flags&D_EXIT)
19399 {
19400 d->flags &= ~D_SELECTED;
19401 object_message(d, MSG_DRAW, 0);
19402 }
19403 }
19404
19405 /* should we close the dialog? */
19406 if(down)
19407 {
19408 onOrgComboAliases();
19409 return D_REDRAW;
19410 }
19411
19412 break;
19413 }
19414
19415 return D_O_K;
19416 }
19417
19418 int32_t d_comboabutton_proc(int32_t msg, DIALOG *d, int32_t c)
19419 {
19420 //these are here to bypass compiler warnings about unused arguments
19421 c=c;
19422
19423 int32_t down=0;
19424 int32_t selected=(d->flags&D_SELECTED)?1:0;
19425 int32_t last_draw;
19426
19427 switch(msg)
19428 {
19429
19430 case MSG_DRAW:
19431 {
19432 FONT *tfont=font;
19433 font=get_zc_font(font_lfont_l);
19434 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
19435 font=tfont;
19436 }
19437 break;
19438
19439 case MSG_WANTFOCUS:
19440 return D_WANTFOCUS;
19441
19442 case MSG_KEY:
19443 /* close dialog? */
19444 onNewComboAlias();
19445 return D_REDRAW;
19446
19447 /* or just toggle */
19448 /*d->flags ^= D_SELECTED;
19449 object_message(d, MSG_DRAW, 0);
19450 break;*/
19451
19452 case MSG_CLICK:
19453 last_draw = 0;
19454
19455 /* track the mouse until it is released */
19456 while(gui_mouse_b())
19457 {
19458 down = mouse_in_rect(d->x, d->y, d->w, d->h);
19459
19460 /* redraw? */
19461 if(last_draw != down)
19462 {
19463 if(down != selected)
19464 d->flags |= D_SELECTED;
19465 else
19466 d->flags &= ~D_SELECTED;
19467
19468 object_message(d, MSG_DRAW, 0);
19469 last_draw = down;
19470 }
19471
19472 /* let other objects continue to animate */
19473 broadcast_dialog_message(MSG_IDLE, 0);
19474 }
19475
19476 /* redraw in normal state */
19477 if(down)
19478 {
19479 if(d->flags&D_EXIT)
19480 {
19481 d->flags &= ~D_SELECTED;
19482 object_message(d, MSG_DRAW, 0);
19483 }
19484 }
19485
19486 /* should we close the dialog? */
19487 if(down)
19488 {
19489 onNewComboAlias();
19490 return D_REDRAW;
19491 }
19492
19493 break;
19494 }
19495
19496 return D_O_K;
19497 }
19498
19499 int32_t d_comboacheck_proc(int32_t msg, DIALOG *d, int32_t c)
19500 {
19501 int32_t temp = d->flags&D_SELECTED;
19502 int32_t ret=jwin_checkfont_proc(msg,d,c);
19503
19504 if(temp != (d->flags&D_SELECTED))
19505 {
19506 return D_REDRAW;
19507 }
19508
19509 return ret;
19510 }
19511
19512 9 static ListData comboa_list(comboalist, &font);
19513
19514 static DIALOG editcomboa_dlg[] =
19515 {
19516 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
19517 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Edit", NULL, NULL },
19518 { jwin_button_proc, 148, 212, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
19519 { jwin_button_proc, 232, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19520 { jwin_frame_proc, 4+121, 28+81, 1, 1, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19521 { d_comboabutton_proc, 25, 212, 81, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Properties", NULL, NULL },
19522 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19523 { d_comboa_radio_proc, 285, 44, 30, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "0", NULL, NULL },
19524 { d_comboa_radio_proc, 285, 54, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
19525 { d_comboa_radio_proc, 285, 64, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
19526 { d_comboa_radio_proc, 285, 74, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
19527 { d_comboa_radio_proc, 285, 84, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
19528
19529 { d_comboa_radio_proc, 285, 94, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
19530 { d_comboa_radio_proc, 285, 104, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
19531 { d_comboacheck_proc, 285, 164, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
19532 { d_comboa_proc, 6, 27, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19533 { jwin_ctext_proc, 290, 176, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Only Show", NULL, NULL },
19534 { jwin_ctext_proc, 290, 186, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Current", NULL, NULL },
19535 { jwin_ctext_proc, 290, 196, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Layer", NULL, NULL },
19536 { jwin_ctext_proc, 290, 122, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Thumbnail", NULL, NULL },
19537 { jwin_frame_proc, 280, 132, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19538 { d_comboat_proc, 282, 134, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19539
19540 //21
19541 { d_orgcomboa_proc, 106, 212, 21, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Org", NULL, NULL },
19542 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19543 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19544 };
19545
19546 int32_t getcurrentcomboalias()
19547 {
19548 return editcomboa_dlg[5].d1;
19549 }
19550
19551 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c)
19552 {
19553 int32_t temp = layer_cnt;
19554 int32_t ret = jwin_radiofont_proc(msg,d,c);
19555
19556 if(editcomboa_dlg[6].flags&D_SELECTED) layer_cnt=0;
19557 else if(editcomboa_dlg[7].flags&D_SELECTED) layer_cnt=1;
19558 else if(editcomboa_dlg[8].flags&D_SELECTED) layer_cnt=2;
19559 else if(editcomboa_dlg[9].flags&D_SELECTED) layer_cnt=3;
19560 else if(editcomboa_dlg[10].flags&D_SELECTED) layer_cnt=4;
19561 else if(editcomboa_dlg[11].flags&D_SELECTED) layer_cnt=5;
19562 else if(editcomboa_dlg[12].flags&D_SELECTED) layer_cnt=6;
19563
19564 if(temp != layer_cnt)
19565 {
19566 return D_REDRAW;
19567 }
19568
19569 return ret;
19570 }
19571
19572 int32_t set_comboaradio(byte layermask)
19573 {
19574 if(editcomboa_dlg[7].flags&D_SELECTED) editcomboa_dlg[7].flags &= ~D_SELECTED;
19575
19576 if(editcomboa_dlg[8].flags&D_SELECTED) editcomboa_dlg[8].flags &= ~D_SELECTED;
19577
19578 if(editcomboa_dlg[9].flags&D_SELECTED) editcomboa_dlg[9].flags &= ~D_SELECTED;
19579
19580 if(editcomboa_dlg[10].flags&D_SELECTED) editcomboa_dlg[10].flags &= ~D_SELECTED;
19581
19582 if(editcomboa_dlg[11].flags&D_SELECTED) editcomboa_dlg[11].flags &= ~D_SELECTED;
19583
19584 if(editcomboa_dlg[12].flags&D_SELECTED) editcomboa_dlg[12].flags &= ~D_SELECTED;
19585
19586 if(!(layermask&1)) editcomboa_dlg[7].flags |= D_DISABLED;
19587 else editcomboa_dlg[7].flags &= ~D_DISABLED;
19588
19589 if(!(layermask&2)) editcomboa_dlg[8].flags |= D_DISABLED;
19590 else editcomboa_dlg[8].flags &= ~D_DISABLED;
19591
19592 if(!(layermask&4)) editcomboa_dlg[9].flags |= D_DISABLED;
19593 else editcomboa_dlg[9].flags &= ~D_DISABLED;
19594
19595 if(!(layermask&8)) editcomboa_dlg[10].flags |= D_DISABLED;
19596 else editcomboa_dlg[10].flags &= ~D_DISABLED;
19597
19598 if(!(layermask&16)) editcomboa_dlg[11].flags |= D_DISABLED;
19599 else editcomboa_dlg[11].flags &= ~D_DISABLED;
19600
19601 if(!(layermask&32)) editcomboa_dlg[12].flags |= D_DISABLED;
19602 else editcomboa_dlg[12].flags &= ~D_DISABLED;
19603
19604 editcomboa_dlg[6].flags |= D_SELECTED;
19605 layer_cnt=0;
19606 return 1;
19607 }
19608
19609 int32_t onEditComboPool()
19610 {
19611 call_cpool_dlg(combo_pool_pos);
19612 return D_O_K;
19613 }
19614 int32_t onEditAutoCombo()
19615 {
19616 call_autocombo_dlg(combo_auto_pos);
19617 return D_O_K;
19618 }
19619 int32_t onEditComboAlias()
19620 {
19621 comboa_cnt = combo_apos;
19622 reset_combo_animations();
19623 reset_combo_animations2();
19624
19625 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
19626 temp_aliases[i] = combo_aliases[i];
19627
19628 editcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
19629 set_comboaradio(temp_aliases[comboa_cnt].layermask);
19630 editcomboa_dlg[5].d1 = comboa_cnt;
19631
19632 bool small_d1 = editcomboa_dlg[0].d1==0;
19633 large_dialog(editcomboa_dlg,2);
19634
19635 if(small_d1)
19636 {
19637 for(int32_t i=6; i<=12; i++)
19638 {
19639 editcomboa_dlg[i].w=30*1.5;
19640 editcomboa_dlg[i].h=9*1.5;
19641 }
19642
19643 editcomboa_dlg[13].w=17*1.5;
19644 editcomboa_dlg[13].h=9*1.5;
19645 editcomboa_dlg[4].w=81*1.5;
19646 editcomboa_dlg[4].h=21*1.5;
19647 editcomboa_dlg[4].dp2=get_zc_font(font_lfont_l);
19648 editcomboa_dlg[21].w=21*1.5;
19649 editcomboa_dlg[21].h=21*1.5;
19650 editcomboa_dlg[21].dp2=get_zc_font(font_lfont_l);
19651 }
19652
19653 int32_t ret=do_zqdialog(editcomboa_dlg,-1);
19654
19655 if(ret==1)
19656 {
19657 saved=false;
19658
19659 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
19660 combo_aliases[i] = temp_aliases[i];
19661 }
19662
19663 setup_combo_animations();
19664 setup_combo_animations2();
19665 return D_O_K;
19666 }
19667 void call_calias_dlg(int index)
19668 {
19669 combo_apos = comboa_cnt = index;
19670 onEditComboAlias();
19671 }
19672
19673 static char ffcombo_str_buf[MAXFFCS];
19674 static char fflink_str_buf[MAXFFCS];
19675
19676 BITMAP* ffcur;
19677
19678 const char *ffcombolist(int32_t index, int32_t *list_size)
19679 {
19680 if(index>=0)
19681 {
19682 bound(index,0,MAXFFCS-1);
19683 sprintf(ffcombo_str_buf,"%d",index+1);
19684 return ffcombo_str_buf;
19685 }
19686
19687 *list_size=MAXFFCS;
19688 return NULL;
19689 }
19690
19691 9 static ListData ffcombo_list(ffcombolist, &font);
19692
19693 static DIALOG ffcombo_sel_dlg[] =
19694 {
19695 9 { jwin_win_proc, 0, 0, 200, 179, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Choose Freeform Combo", NULL, NULL },
19696 9 { jwin_button_proc, 35, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
19697 9 { jwin_button_proc, 104, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
19698 9 { d_ffcombolist_proc, 11, 24, 49, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &ffcombo_list, NULL, NULL },
19699 9 { d_comboframe_proc, 68, 23, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
19700 9 { d_bitmap_proc, 70, 25, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19701 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19702 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19703 };
19704
19705 int32_t d_ffcombolist_proc(int32_t msg,DIALOG *d,int32_t c)
19706 {
19707 int32_t ret = jwin_droplist_proc(msg,d,c);
19708 int32_t d1 = d->d1;
19709 int32_t x=ffcombo_sel_dlg[0].x;
19710 int32_t y=ffcombo_sel_dlg[0].y;
19711 FONT *tempfont=(font);
19712 int32_t x2=text_length(tempfont, "Move Delay:")+4;
19713
19714 switch(msg)
19715 {
19716 case MSG_DRAW:
19717 if(!ffcur) return D_O_K;
19718
19719 BITMAP *buf = create_bitmap_ex(8,16,16);
19720
19721 if(buf)
19722 {
19723 clear_bitmap(buf);
19724 putcombo(buf,0,0,Map.CurrScr()->ffcs[d1].data,Map.CurrScr()->ffcs[d1].cset);
19725 stretch_blit(buf, ffcur, 0,0, 16, 16, 0, 0, ffcur->w, ffcur->h);
19726 destroy_bitmap(buf);
19727 }
19728
19729 object_message(&ffcombo_sel_dlg[5],MSG_DRAW,0);
19730
19731 int32_t xd = x+int32_t(68*1.5);
19732 int32_t y2 = y+int32_t(55*1.5);
19733 int32_t yd = 9;
19734
19735 rectfill(screen,xd,y2,xd+x2+100,y2+yd*14,jwin_pal[jcBOX]);
19736
19737 textprintf_ex(screen,tempfont,xd,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo #:");
19738 textprintf_ex(screen,tempfont,xd+x2,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].data);
19739
19740 textprintf_ex(screen,tempfont,xd,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"CSet #:");
19741 textprintf_ex(screen,tempfont,xd+x2,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].cset);
19742
19743 textprintf_ex(screen,tempfont,xd,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Pos:");
19744 textprintf_ex(screen,tempfont,xd+x2,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].x.getFloat());
19745
19746 textprintf_ex(screen,tempfont,xd,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Pos:");
19747 textprintf_ex(screen,tempfont,xd+x2,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].y.getFloat());
19748
19749 textprintf_ex(screen,tempfont,xd,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Speed:");
19750 textprintf_ex(screen,tempfont,xd+x2,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vx.getFloat());
19751
19752 textprintf_ex(screen,tempfont,xd,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Speed:");
19753 textprintf_ex(screen,tempfont,xd+x2,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vy.getFloat());
19754
19755 textprintf_ex(screen,tempfont,xd,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Accel:");
19756 textprintf_ex(screen,tempfont,xd+x2,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ax.getFloat());
19757
19758 textprintf_ex(screen,tempfont,xd,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Accel:");
19759 textprintf_ex(screen,tempfont,xd+x2,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ay.getFloat());
19760
19761 textprintf_ex(screen,tempfont,xd,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Linked To:");
19762 textprintf_ex(screen,tempfont,xd+x2,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].link);
19763
19764 textprintf_ex(screen,tempfont,xd,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Move Delay:");
19765 textprintf_ex(screen,tempfont,xd+x2,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].delay);
19766
19767 textprintf_ex(screen,tempfont,xd,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo W:");
19768 textprintf_ex(screen,tempfont,xd+x2,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectWidth(d1)));
19769
19770 textprintf_ex(screen,tempfont,xd,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo H:");
19771 textprintf_ex(screen,tempfont,xd+x2,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectHeight(d1)));
19772
19773 textprintf_ex(screen,tempfont,xd,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile W:");
19774 textprintf_ex(screen,tempfont,xd+x2,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileWidth(d1)));
19775
19776 textprintf_ex(screen,tempfont,xd,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile H:");
19777 textprintf_ex(screen,tempfont,xd+x2,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileHeight(d1)));
19778
19779 break;
19780 }
19781
19782 return ret;
19783 }
19784 int32_t onSelectFFCombo()
19785 {
19786 ffcombo_sel_dlg[0].dp2 = get_zc_font(font_lfont);
19787 ffcombo_sel_dlg[3].d1 = ff_combo;
19788 ffcur = create_bitmap_ex(8,32,32);
19789
19790 if(!ffcur) return D_O_K;
19791
19792 putcombo(ffcur,0,0,Map.CurrScr()->ffcs[ff_combo].data,Map.CurrScr()->ffcs[ff_combo].cset);
19793 ffcombo_sel_dlg[5].dp = ffcur;
19794
19795 bool resize = !(ffcombo_sel_dlg[0].d1);
19796 large_dialog(ffcombo_sel_dlg);
19797
19798 if(resize)
19799 {
19800 ffcombo_sel_dlg[5].x--;
19801 ffcombo_sel_dlg[5].y--;
19802 }
19803
19804 int32_t ret=do_zqdialog(ffcombo_sel_dlg,0);
19805
19806 while(ret==1)
19807 {
19808 ff_combo = ffcombo_sel_dlg[3].d1;
19809 call_ffc_dialog(ff_combo);
19810 ret=do_zqdialog(ffcombo_sel_dlg,0);
19811 }
19812
19813 destroy_bitmap(ffcur);
19814 return D_O_K;
19815 }
19816
19817 const char *globalscriptlist(int32_t index, int32_t *list_size);
19818 9 static ListData globalscript_list(globalscriptlist, &font);
19819 const char *playerscriptlist(int32_t index, int32_t *list_size);
19820 9 static ListData playerscript_list(playerscriptlist, &font);
19821
19822 const char *ffscriptlist(int32_t index, int32_t *list_size);
19823
19824 9 static ListData ffscript_list(ffscriptlist, &font);
19825
19826 char *strip_decimals(char *string)
19827 {
19828 int32_t len=(int32_t)strlen(string);
19829 char *src=(char *)malloc(len+1);
19830 char *tmpsrc=src;
19831 memcpy(src,string,len+1);
19832 memset(src,0,len+1);
19833
19834 for(size_t i=0; string[i]&&i<=strlen(string); i++)
19835 {
19836 *tmpsrc=string[i];
19837
19838 if(*tmpsrc=='.')
19839 {
19840 while(string[i+1]=='.'&&i<=strlen(string))
19841 {
19842 i++;
19843 }
19844 }
19845
19846 tmpsrc++;
19847 }
19848
19849 memcpy(string,src,len);
19850 free(src);
19851 return string;
19852 }
19853
19854 // Unused??? -L 6/6/11
19855 char *clean_numeric_string(char *string)
19856 {
19857 bool found_sign=false;
19858 bool found_decimal=false;
19859 int32_t len=(int32_t)strlen(string);
19860 char *src=(char *)malloc(len+1);
19861 char *tmpsrc=src;
19862 memcpy(src,string,len+1);
19863 memset(src,0,len+1);
19864
19865 // strip out non-numerical characters
19866 for(size_t i=0; string[i]&&i<=strlen(string); i++)
19867 {
19868 *tmpsrc=string[i];
19869
19870 if(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
19871 {
19872 while(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
19873 {
19874 i++;
19875 }
19876 }
19877
19878 tmpsrc++;
19879 }
19880
19881 len=(int32_t)strlen(src);
19882 char *src2=(char *)malloc(len+1);
19883 tmpsrc=src2;
19884 memcpy(src,src2,len+1);
19885 memset(src2,0,len+1);
19886
19887 // second purge
19888 for(size_t i=0; src[i]&&i<=strlen(src); i++)
19889 {
19890 *tmpsrc=src[i];
19891
19892 if(*tmpsrc=='-'||*tmpsrc=='+')
19893 {
19894 if(found_sign||found_decimal)
19895 {
19896 while(*tmpsrc=='-'||*tmpsrc=='+')
19897 {
19898 i++;
19899 }
19900 }
19901
19902 found_sign=true;
19903 }
19904
19905 if(*tmpsrc=='.')
19906 {
19907 if(found_decimal)
19908 {
19909 while(*tmpsrc=='.')
19910 {
19911 i++;
19912 }
19913 }
19914
19915 found_decimal=true;
19916 }
19917
19918 tmpsrc++;
19919 }
19920
19921 sprintf(string, "%s", src2);
19922 free(src);
19923 free(src2);
19924 return string;
19925 }
19926
19927 script_struct biglobal[NUMSCRIPTGLOBAL+1]; //global script
19928 int32_t biglobal_cnt = -1;
19929 script_struct biffs[NUMSCRIPTFFC]; //ff script
19930 int32_t biffs_cnt = -1;
19931 script_struct biitems[NUMSCRIPTITEM]; //item script
19932 int32_t biitems_cnt = -1;
19933 script_struct binpcs[NUMSCRIPTGUYS]; //npc script
19934 int32_t binpcs_cnt = -1;
19935
19936 script_struct bilweapons[NUMSCRIPTWEAPONS]; //lweapon script
19937 int32_t bilweapons_cnt = -1;
19938
19939 script_struct bieweapons[NUMSCRIPTWEAPONS]; //eweapon script
19940 int32_t bieweapons_cnt = -1;
19941
19942 script_struct bihero[NUMSCRIPTPLAYER]; //link script
19943 int32_t bihero_cnt = -1;
19944
19945 script_struct biscreens[NUMSCRIPTSCREEN]; //screen (screendata) script
19946 int32_t biscreens_cnt = -1;
19947
19948 script_struct bidmaps[NUMSCRIPTSDMAP]; //dmap (dmapdata) script
19949 int32_t bidmaps_cnt = -1;
19950
19951 script_struct biditemsprites[NUMSCRIPTSITEMSPRITE]; //dmap (dmapdata) script
19952 int32_t biitemsprites_cnt = -1;
19953
19954 script_struct bidcomboscripts[NUMSCRIPTSCOMBODATA]; //dmap (dmapdata) script
19955 int32_t bidcomboscripts_cnt = -1;
19956 //static char ffscript_str_buf[32];
19957
19958 void build_biglobal_list()
19959 {
19960 biglobal[0].first = "(None)";
19961 biglobal[0].second = -1;
19962 biglobal_cnt = 1;
19963
19964 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
19965 {
19966 if(globalmap[i].scriptname.length()==0)
19967 continue;
19968
19969 stringstream ss;
19970 ss << globalmap[i].scriptname << " (" << i << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19971 biglobal[biglobal_cnt].first = ss.str();
19972 biglobal[biglobal_cnt].second = i;
19973 ++biglobal_cnt;
19974 }
19975
19976 // Blank out the rest of the list
19977 for(int32_t i=biglobal_cnt; i<NUMSCRIPTGLOBAL; ++i)
19978 {
19979 biglobal[i].first="";
19980 biglobal[i].second=-1;
19981 }
19982
19983 //Bubble sort! (doesn't account for gaps between scripts)
19984 for(int32_t i = 0; i < biglobal_cnt - 1; i++)
19985 {
19986 for(int32_t j = i + 1; j < biglobal_cnt; j++)
19987 {
19988 if(stricmp(biglobal[i].first.c_str(),biglobal[j].first.c_str()) > 0 && strcmp(biglobal[j].first.c_str(),""))
19989 zc_swap(biglobal[i],biglobal[j]);
19990 }
19991 }
19992
19993 biglobal_cnt = 0;
19994
19995 for(int32_t i = 0; i < NUMSCRIPTGLOBAL+1; ++i)
19996 if(biglobal[i].first.length() > 0)
19997 biglobal_cnt = i+1;
19998 }
19999
20000 4 void build_biffs_list()
20001 {
20002 4 biffs[0].first = "(None)";
20003 4 biffs[0].second = -1;
20004 4 biffs_cnt = 1;
20005
20006
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTFFC - 1; i++)
20007 {
20008
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 1971 times.
2044 if(ffcmap[i].scriptname.length()==0)
20009 1971 continue;
20010
20011 73 stringstream ss;
20012
5/10
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 73 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 73 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 73 times.
✗ Branch 9 not taken.
73 ss << ffcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20013
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 biffs[biffs_cnt].first = ss.str();
20014 73 biffs[biffs_cnt].second = i;
20015 73 biffs_cnt++;
20016 73 }
20017
20018 // Blank out the rest of the list
20019
2/2
✓ Branch 0 taken 1971 times.
✓ Branch 1 taken 4 times.
1975 for(int32_t i=biffs_cnt; i<NUMSCRIPTFFC; i++)
20020 {
20021 1971 biffs[i].first="";
20022 1971 biffs[i].second=-1;
20023 1971 }
20024
20025 //Bubble sort! (doesn't account for gaps between scripts)
20026
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 4 times.
77 for(int32_t i = 0; i < biffs_cnt - 1; i++)
20027 {
20028
2/2
✓ Branch 0 taken 1318 times.
✓ Branch 1 taken 73 times.
1391 for(int32_t j = i + 1; j < biffs_cnt; j++)
20029 {
20030
3/4
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 535 times.
1318 if(stricmp(biffs[i].first.c_str(),biffs[j].first.c_str()) > 0 && strcmp(biffs[j].first.c_str(),""))
20031 535 zc_swap(biffs[i],biffs[j]);
20032 1318 }
20033 73 }
20034
20035 4 biffs_cnt = 0;
20036
20037
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i = 0; i < NUMSCRIPTFFC; i++)
20038
2/2
✓ Branch 0 taken 1971 times.
✓ Branch 1 taken 77 times.
2125 if(biffs[i].first.length() > 0)
20039 77 biffs_cnt = i+1;
20040 4 }
20041
20042 //npc scripts
20043 void build_binpcs_list()
20044 {
20045 binpcs[0].first = "(None)";
20046 binpcs[0].second = -1;
20047 binpcs_cnt = 1;
20048
20049 for(int32_t i = 0; i < NUMSCRIPTGUYS - 1; i++)
20050 {
20051 if(npcmap[i].scriptname.length()==0)
20052 continue;
20053
20054 stringstream ss;
20055 ss << npcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20056 binpcs[binpcs_cnt].first = ss.str();
20057 binpcs[binpcs_cnt].second = i;
20058 binpcs_cnt++;
20059 }
20060
20061 // Blank out the rest of the list
20062 for(int32_t i=binpcs_cnt; i<NUMSCRIPTGUYS; i++)
20063 {
20064 binpcs[i].first="";
20065 binpcs[i].second=-1;
20066 }
20067
20068 //Bubble sort! (doesn't account for gaps between scripts)
20069 for(int32_t i = 0; i < binpcs_cnt - 1; i++)
20070 {
20071 for(int32_t j = i + 1; j < binpcs_cnt; j++)
20072 {
20073 if(stricmp(binpcs[i].first.c_str(),binpcs[j].first.c_str()) > 0 && strcmp(binpcs[j].first.c_str(),""))
20074 zc_swap(binpcs[i],binpcs[j]);
20075 }
20076 }
20077
20078 binpcs_cnt = 0;
20079
20080 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
20081 if(binpcs[i].first.length() > 0)
20082 binpcs_cnt = i+1;
20083 }
20084
20085
20086 //lweapon scripts
20087 void build_bilweapons_list()
20088 {
20089 bilweapons[0].first = "(None)";
20090 bilweapons[0].second = -1;
20091 bilweapons_cnt = 1;
20092
20093 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
20094 {
20095 if(lwpnmap[i].scriptname.length()==0)
20096 continue;
20097
20098 stringstream ss;
20099 ss << lwpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20100 bilweapons[bilweapons_cnt].first = ss.str();
20101 bilweapons[bilweapons_cnt].second = i;
20102 bilweapons_cnt++;
20103 }
20104
20105 // Blank out the rest of the list
20106 for(int32_t i=bilweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
20107 {
20108 bilweapons[i].first="";
20109 bilweapons[i].second=-1;
20110 }
20111
20112 //Bubble sort! (doesn't account for gaps between scripts)
20113 for(int32_t i = 0; i < bilweapons_cnt - 1; i++)
20114 {
20115 for(int32_t j = i + 1; j < bilweapons_cnt; j++)
20116 {
20117 if(stricmp(bilweapons[i].first.c_str(),bilweapons[j].first.c_str()) > 0 && strcmp(bilweapons[j].first.c_str(),""))
20118 zc_swap(bilweapons[i],bilweapons[j]);
20119 }
20120 }
20121
20122 bilweapons_cnt = 0;
20123
20124 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
20125 if(bilweapons[i].first.length() > 0)
20126 bilweapons_cnt = i+1;
20127 }
20128
20129 //eweapon scripts
20130 void build_bieweapons_list()
20131 {
20132 bieweapons[0].first = "(None)";
20133 bieweapons[0].second = -1;
20134 bieweapons_cnt = 1;
20135
20136 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
20137 {
20138 if(ewpnmap[i].scriptname.length()==0)
20139 continue;
20140
20141 stringstream ss;
20142 ss << ewpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20143 bieweapons[bieweapons_cnt].first = ss.str();
20144 bieweapons[bieweapons_cnt].second = i;
20145 bieweapons_cnt++;
20146 }
20147
20148 // Blank out the rest of the list
20149 for(int32_t i=bieweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
20150 {
20151 bieweapons[i].first="";
20152 bieweapons[i].second=-1;
20153 }
20154
20155 //Bubble sort! (doesn't account for gaps between scripts)
20156 for(int32_t i = 0; i < bieweapons_cnt - 1; i++)
20157 {
20158 for(int32_t j = i + 1; j < bieweapons_cnt; j++)
20159 {
20160 if(stricmp(bieweapons[i].first.c_str(),bieweapons[j].first.c_str()) > 0 && strcmp(bieweapons[j].first.c_str(),""))
20161 zc_swap(bieweapons[i],bieweapons[j]);
20162 }
20163 }
20164
20165 bieweapons_cnt = 0;
20166
20167 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
20168 if(bieweapons[i].first.length() > 0)
20169 bieweapons_cnt = i+1;
20170 }
20171
20172 //player scripts
20173 void build_bihero_list()
20174 {
20175 bihero[0].first = "(None)";
20176 bihero[0].second = -1;
20177 bihero_cnt = 1;
20178
20179 for(int32_t i = 0; i < NUMSCRIPTPLAYER - 1; i++)
20180 {
20181 if(playermap[i].scriptname.length()==0)
20182 continue;
20183
20184 stringstream ss;
20185 ss << playermap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20186 bihero[bihero_cnt].first = ss.str();
20187 bihero[bihero_cnt].second = i;
20188 bihero_cnt++;
20189 }
20190
20191 // Blank out the rest of the list
20192 for(int32_t i=bihero_cnt; i<NUMSCRIPTPLAYER; i++)
20193 {
20194 bihero[i].first="";
20195 bihero[i].second=-1;
20196 }
20197
20198 //Bubble sort! (doesn't account for gaps between scripts)
20199 for(int32_t i = 0; i < bihero_cnt - 1; i++)
20200 {
20201 for(int32_t j = i + 1; j < bihero_cnt; j++)
20202 {
20203 if(stricmp(bihero[i].first.c_str(),bihero[j].first.c_str()) > 0 && strcmp(bihero[j].first.c_str(),""))
20204 zc_swap(bihero[i],bihero[j]);
20205 }
20206 }
20207
20208 bihero_cnt = 0;
20209
20210 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
20211 if(bihero[i].first.length() > 0)
20212 bihero_cnt = i+1;
20213 }
20214
20215 //dmap scripts
20216 void build_bidmaps_list()
20217 {
20218 bidmaps[0].first = "(None)";
20219 bidmaps[0].second = -1;
20220 bidmaps_cnt = 1;
20221
20222 for(int32_t i = 0; i < NUMSCRIPTSDMAP - 1; i++)
20223 {
20224 if(dmapmap[i].scriptname.length()==0)
20225 continue;
20226
20227 stringstream ss;
20228 ss << dmapmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20229 bidmaps[bidmaps_cnt].first = ss.str();
20230 bidmaps[bidmaps_cnt].second = i;
20231 bidmaps_cnt++;
20232 }
20233
20234 // Blank out the rest of the list
20235 for(int32_t i=bidmaps_cnt; i<NUMSCRIPTSDMAP; i++)
20236 {
20237 bidmaps[i].first="";
20238 bidmaps[i].second=-1;
20239 }
20240
20241 //Bubble sort! (doesn't account for gaps between scripts)
20242 for(int32_t i = 0; i < bidmaps_cnt - 1; i++)
20243 {
20244 for(int32_t j = i + 1; j < bidmaps_cnt; j++)
20245 {
20246 if(stricmp(bidmaps[i].first.c_str(),bidmaps[j].first.c_str()) > 0 && strcmp(bidmaps[j].first.c_str(),""))
20247 zc_swap(bidmaps[i],bidmaps[j]);
20248 }
20249 }
20250
20251 bidmaps_cnt = 0;
20252
20253 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
20254 if(bidmaps[i].first.length() > 0)
20255 bidmaps_cnt = i+1;
20256 }
20257
20258 //screen scripts
20259 void build_biscreens_list()
20260 {
20261 biscreens[0].first = "(None)";
20262 biscreens[0].second = -1;
20263 biscreens_cnt = 1;
20264
20265 for(int32_t i = 0; i < NUMSCRIPTSCREEN - 1; i++)
20266 {
20267 if(screenmap[i].scriptname.length()==0)
20268 continue;
20269
20270 stringstream ss;
20271 ss << screenmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20272 biscreens[biscreens_cnt].first = ss.str();
20273 biscreens[biscreens_cnt].second = i;
20274 biscreens_cnt++;
20275 }
20276
20277 // Blank out the rest of the list
20278 for(int32_t i=biscreens_cnt; i<NUMSCRIPTSCREEN; i++)
20279 {
20280 biscreens[i].first="";
20281 biscreens[i].second=-1;
20282 }
20283
20284 //Bubble sort! (doesn't account for gaps between scripts)
20285 for(int32_t i = 0; i < biscreens_cnt - 1; i++)
20286 {
20287 for(int32_t j = i + 1; j < biscreens_cnt; j++)
20288 {
20289 if(stricmp(biscreens[i].first.c_str(),biscreens[j].first.c_str()) > 0 && strcmp(biscreens[j].first.c_str(),""))
20290 zc_swap(biscreens[i],biscreens[j]);
20291 }
20292 }
20293
20294 biscreens_cnt = 0;
20295
20296 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
20297 if(biscreens[i].first.length() > 0)
20298 biscreens_cnt = i+1;
20299 }
20300
20301 //screen scripts
20302 void build_biitemsprites_list()
20303 {
20304 biditemsprites[0].first = "(None)";
20305 biditemsprites[0].second = -1;
20306 biitemsprites_cnt = 1;
20307
20308 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE - 1; i++)
20309 {
20310 if(itemspritemap[i].scriptname.length()==0)
20311 continue;
20312
20313 stringstream ss;
20314 ss << itemspritemap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20315 biditemsprites[biitemsprites_cnt].first = ss.str();
20316 biditemsprites[biitemsprites_cnt].second = i;
20317 biitemsprites_cnt++;
20318 }
20319
20320 // Blank out the rest of the list
20321 for(int32_t i=biitemsprites_cnt; i<NUMSCRIPTSITEMSPRITE; i++)
20322 {
20323 biditemsprites[i].first="";
20324 biditemsprites[i].second=-1;
20325 }
20326
20327 //Bubble sort! (doesn't account for gaps between scripts)
20328 for(int32_t i = 0; i < biitemsprites_cnt - 1; i++)
20329 {
20330 for(int32_t j = i + 1; j < biitemsprites_cnt; j++)
20331 {
20332 if(stricmp(biditemsprites[i].first.c_str(),biditemsprites[j].first.c_str()) > 0 && strcmp(biditemsprites[j].first.c_str(),""))
20333 zc_swap(biditemsprites[i],biditemsprites[j]);
20334 }
20335 }
20336
20337 biitemsprites_cnt = 0;
20338
20339 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
20340 if(biditemsprites[i].first.length() > 0)
20341 biitemsprites_cnt = i+1;
20342 }
20343
20344 4 void build_biitems_list()
20345 {
20346 4 biitems[0].first = "(None)";
20347 4 biitems[0].second = -1;
20348 4 biitems_cnt = 1;
20349
20350
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTITEM - 1; i++, biitems_cnt++)
20351 {
20352 1020 stringstream ss;
20353
20354
4/6
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1020 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1008 times.
1020 if(!itemmap[i].isEmpty())
20355
5/10
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
12 ss << itemmap[i].scriptname << " (" << i+1 << ")";
20356
20357
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 biitems[biitems_cnt].first = ss.str();
20358 1020 biitems[biitems_cnt].second = i;
20359 1020 }
20360
20361
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < biitems_cnt - 1; i++)
20362 {
20363
2/2
✓ Branch 0 taken 130560 times.
✓ Branch 1 taken 1020 times.
131580 for(int32_t j = i + 1; j < biitems_cnt; j++)
20364 {
20365
4/4
✓ Branch 0 taken 3997 times.
✓ Branch 1 taken 126563 times.
✓ Branch 2 taken 3994 times.
✓ Branch 3 taken 3 times.
130560 if(stricmp(biitems[i].first.c_str(), biitems[j].first.c_str()) > 0 && strcmp(biitems[j].first.c_str(),""))
20366 3 zc_swap(biitems[i], biitems[j]);
20367 130560 }
20368 1020 }
20369
20370 4 biitems_cnt = 0;
20371
20372
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
20373
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 16 times.
1040 if(biitems[i].first.length() > 0)
20374 16 biitems_cnt = i+1;
20375 4 }
20376
20377
20378 //dmap scripts
20379 void build_bidcomboscripts_list()
20380 {
20381 bidcomboscripts[0].first = "(None)";
20382 bidcomboscripts[0].second = -1;
20383 bidcomboscripts_cnt = 1;
20384
20385 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA - 1; i++)
20386 {
20387 if(comboscriptmap[i].scriptname.length()==0)
20388 continue;
20389
20390 stringstream ss;
20391 ss << comboscriptmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
20392 bidcomboscripts[bidcomboscripts_cnt].first = ss.str();
20393 bidcomboscripts[bidcomboscripts_cnt].second = i;
20394 bidcomboscripts_cnt++;
20395 }
20396
20397 // Blank out the rest of the list
20398 for(int32_t i=bidcomboscripts_cnt; i<NUMSCRIPTSCOMBODATA; i++)
20399 {
20400 bidcomboscripts[i].first="";
20401 bidcomboscripts[i].second=-1;
20402 }
20403
20404 //Bubble sort! (doesn't account for gaps between scripts)
20405 for(int32_t i = 0; i < bidcomboscripts_cnt - 1; i++)
20406 {
20407 for(int32_t j = i + 1; j < bidcomboscripts_cnt; j++)
20408 {
20409 if(stricmp(bidcomboscripts[i].first.c_str(),bidcomboscripts[j].first.c_str()) > 0 && strcmp(bidcomboscripts[j].first.c_str(),""))
20410 zc_swap(bidcomboscripts[i],bidcomboscripts[j]);
20411 }
20412 }
20413
20414 bidcomboscripts_cnt = 0;
20415
20416 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
20417 if(bidcomboscripts[i].first.length() > 0)
20418 bidcomboscripts_cnt = i+1;
20419 }
20420
20421
20422 const char *globalscriptlist(int32_t index, int32_t *list_size)
20423 {
20424 if(index < 0)
20425 {
20426 *list_size = biglobal_cnt;
20427 return NULL;
20428 }
20429
20430 return biglobal[index].first.c_str();
20431 }
20432
20433 const char *ffscriptlist(int32_t index, int32_t *list_size)
20434 {
20435 if(index < 0)
20436 {
20437 *list_size = biffs_cnt;
20438 return NULL;
20439 }
20440
20441 return biffs[index].first.c_str();
20442 }
20443
20444 const char *playerscriptlist(int32_t index, int32_t *list_size)
20445 {
20446 if(index < 0)
20447 {
20448 *list_size = bihero_cnt;
20449 return NULL;
20450 }
20451
20452 return bihero[index].first.c_str();
20453 }
20454
20455 const char *lweaponscriptlist(int32_t index, int32_t *list_size)
20456 {
20457 if(index < 0)
20458 {
20459 *list_size = bilweapons_cnt;
20460 return NULL;
20461 }
20462
20463 return bilweapons[index].first.c_str();
20464 }
20465
20466 const char *npcscriptlist(int32_t index, int32_t *list_size)
20467 {
20468 if(index < 0)
20469 {
20470 *list_size = binpcs_cnt;
20471 return NULL;
20472 }
20473
20474 return binpcs[index].first.c_str();
20475 }
20476
20477 static char itemscript_str_buf[32];
20478
20479 char *itemscriptlist(int32_t index, int32_t *list_size)
20480 {
20481 if(index>=0)
20482 {
20483 bound(index,0,255);
20484 sprintf(itemscript_str_buf,"%d: %s",index, ffcmap[index-1].scriptname.c_str());
20485 return itemscript_str_buf;
20486 }
20487
20488 *list_size=256;
20489 return NULL;
20490 }
20491
20492 static char ffscript_str_buf2[32];
20493
20494 const char *ffscriptlist2(int32_t index, int32_t *list_size)
20495 {
20496 if(index>=0)
20497 {
20498 char buf[20];
20499 bound(index,0,510);
20500
20501 if(ffcmap[index].scriptname=="")
20502 strcpy(buf, "<none>");
20503 else
20504 {
20505 strncpy(buf, ffcmap[index].scriptname.c_str(), 19);
20506 buf[19]='\0';
20507 }
20508
20509 sprintf(ffscript_str_buf2,"%d: %s",index+1, buf);
20510 return ffscript_str_buf2;
20511 }
20512
20513 *list_size=511;
20514 return NULL;
20515 }
20516
20517 static char itemscript_str_buf2[32];
20518
20519 const char *itemscriptlist2(int32_t index, int32_t *list_size)
20520 {
20521 if(index>=0)
20522 {
20523 char buf[20];
20524 bound(index,0,254);
20525
20526 if(itemmap[index].scriptname=="")
20527 strcpy(buf, "<none>");
20528 else
20529 {
20530 strncpy(buf, itemmap[index].scriptname.c_str(), 19);
20531 buf[19]='\0';
20532 }
20533
20534 sprintf(itemscript_str_buf2,"%d: %s",index+1, buf);
20535 return itemscript_str_buf2;
20536 }
20537
20538 *list_size=255;
20539 return NULL;
20540 }
20541
20542
20543 static char comboscript_str_buf2[32];
20544 const char *comboscriptlist2(int32_t index, int32_t *list_size)
20545 {
20546 if(index>=0)
20547 {
20548 char buf[20];
20549 bound(index,0,254);
20550
20551 if(comboscriptmap[index].scriptname=="")
20552 strcpy(buf, "<none>");
20553 else
20554 {
20555 strncpy(buf, comboscriptmap[index].scriptname.c_str(), 19);
20556 buf[19]='\0';
20557 }
20558
20559 sprintf(comboscript_str_buf2,"%d: %s",index+1, buf);
20560 return comboscript_str_buf2;
20561 }
20562
20563 *list_size=255;
20564 return NULL;
20565 }
20566
20567 static char gscript_str_buf2[40];
20568
20569 const char *gscriptlist2(int32_t index, int32_t *list_size)
20570 {
20571 if(index >= 0)
20572 {
20573 bound(index,0,3);
20574
20575 char buf[20];
20576
20577 if(globalmap[index].scriptname == "")
20578 strcpy(buf, "<none>");
20579 else
20580 {
20581 strncpy(buf, globalmap[index].scriptname.c_str(), 19);
20582 buf[19]='\0';
20583 }
20584
20585 switch(index)
20586 {
20587 case GLOBAL_SCRIPT_INIT:
20588 sprintf(gscript_str_buf2,"Initialization: %s", buf); break;
20589 case GLOBAL_SCRIPT_GAME:
20590 sprintf(gscript_str_buf2,"Active: %s", buf); break;
20591 case GLOBAL_SCRIPT_END:
20592 sprintf(gscript_str_buf2,"onExit: %s", buf); break;
20593 case GLOBAL_SCRIPT_ONSAVELOAD:
20594 sprintf(gscript_str_buf2,"onSaveLoad: %s", buf); break;
20595 case GLOBAL_SCRIPT_ONLAUNCH:
20596 sprintf(gscript_str_buf2,"onLaunch: %s", buf); break;
20597 case GLOBAL_SCRIPT_ONCONTGAME:
20598 sprintf(gscript_str_buf2,"onContGame: %s", buf); break;
20599 case GLOBAL_SCRIPT_F6:
20600 sprintf(gscript_str_buf2,"onF6Menu: %s", buf); break;
20601 case GLOBAL_SCRIPT_ONSAVE:
20602 sprintf(gscript_str_buf2,"onSave: %s", buf); break;
20603 }
20604
20605 return gscript_str_buf2;
20606 }
20607
20608 if(list_size != NULL)
20609 *list_size=4;
20610
20611 return NULL;
20612 }
20613
20614 static int32_t as_ffc_list[] = { 4, 5, 6, -1};
20615 static int32_t as_global_list[] = { 7, 8, 9, -1}; //Why does putting 15 in here not place my message only on the global tab? ~Joe
20616 static int32_t as_item_list[] = { 10, 11, 12, -1};
20617 static int32_t as_npc_list[] = { 18, 19, 20, -1}; //npc scripts TAB
20618 static int32_t as_lweapon_list[] = { 21, 22, 23, -1}; //lweapon scripts TAB
20619 static int32_t as_eweapon_list[] = { 24, 25, 26, -1}; //eweapon scripts TAB
20620 static int32_t as_hero_list[] = { 27, 28, 29, -1}; //player scripts TAB
20621 static int32_t as_screen_list[] = { 30, 31, 32, -1}; //screendata scripts TAB
20622 static int32_t as_dmap_list[] = { 33, 34, 35, -1}; //dmapdata scripts TAB
20623 static int32_t as_itemsprite_list[] = { 36, 37, 38, -1}; //dmapdata scripts TAB
20624 static int32_t as_comboscript_list[] = { 39, 40, 41, -1}; //combodata scripts TAB
20625 static int32_t as_genericscript_list[] = { 45, 46, 47, -1}; //generic scripts TAB
20626 static int32_t as_subscreenscript_list[] = { 48, 49, 50, -1}; //generic scripts TAB
20627
20628 static TABPANEL assignscript_tabs[] =
20629 {
20630 // (text)
20631 { (char *)"FFC", D_SELECTED, as_ffc_list, 0, NULL },
20632 { (char *)"Global", 0, as_global_list, 0, NULL },
20633 { (char *)"Item", 0, as_item_list, 0, NULL },
20634 { (char *)"NPC", 0, as_npc_list, 0, NULL },
20635 { (char *)"LWeapon", 0, as_lweapon_list, 0, NULL },
20636 { (char *)"EWeapon", 0, as_eweapon_list, 0, NULL },
20637 { (char *)"Hero", 0, as_hero_list, 0, NULL },
20638 { (char *)"DMap", 0, as_dmap_list, 0, NULL },
20639 { (char *)"Screen", 0, as_screen_list, 0, NULL },
20640 { (char *)"Item Sprite", 0, as_itemsprite_list, 0, NULL },
20641 { (char *)"Combo", 0, as_comboscript_list, 0, NULL },
20642 { (char *)"Generic", 0, as_genericscript_list, 0, NULL },
20643 { (char *)"Subscreen", 0, as_subscreenscript_list, 0, NULL },
20644 { NULL, 0, NULL, 0, NULL }
20645 };
20646
20647 const char *assignffclist(int32_t index, int32_t *list_size)
20648 {
20649 if(index<0)
20650 {
20651 *list_size = (int32_t)ffcmap.size();
20652 return NULL;
20653 }
20654
20655 return ffcmap[index].output.c_str();
20656 }
20657
20658 const char *assigngloballist(int32_t index, int32_t *list_size)
20659 {
20660 if(index<0)
20661 {
20662 *list_size = (int32_t)globalmap.size();
20663 return NULL;
20664 }
20665
20666 return globalmap[index].output.c_str();
20667 }
20668
20669 const char *assigncombolist(int32_t index, int32_t *list_size)
20670 {
20671 if(index<0)
20672 {
20673 *list_size = (int32_t)comboscriptmap.size();
20674 return NULL;
20675 }
20676
20677 return comboscriptmap[index].output.c_str();
20678 }
20679
20680 const char *assigngenericlist(int32_t index, int32_t *list_size)
20681 {
20682 if(index<0)
20683 {
20684 *list_size = ((int32_t)genericmap.size());
20685 return NULL;
20686 }
20687
20688 return genericmap[index].output.c_str();
20689 }
20690
20691 const char *assignsubscreenlist(int32_t index, int32_t *list_size)
20692 {
20693 if(index<0)
20694 {
20695 *list_size = ((int32_t)subscreenmap.size());
20696 return NULL;
20697 }
20698
20699 return subscreenmap[index].output.c_str();
20700 }
20701
20702 const char *assignitemlist(int32_t index, int32_t *list_size)
20703 {
20704 if(index<0)
20705 {
20706 *list_size = (int32_t)itemmap.size();
20707 return NULL;
20708 }
20709
20710 return itemmap[index].output.c_str();
20711 }
20712 const char *assignnpclist(int32_t index, int32_t *list_size)
20713 {
20714 if(index<0)
20715 {
20716 *list_size = (int32_t)npcmap.size();
20717 return NULL;
20718 }
20719
20720 return npcmap[index].output.c_str();
20721 }
20722
20723 const char *assignlweaponlist(int32_t index, int32_t *list_size)
20724 {
20725 if(index<0)
20726 {
20727 *list_size = (int32_t)lwpnmap.size();
20728 return NULL;
20729 }
20730
20731 return lwpnmap[index].output.c_str();
20732 }
20733
20734 const char *assigneweaponlist(int32_t index, int32_t *list_size)
20735 {
20736 if(index<0)
20737 {
20738 *list_size = (int32_t)ewpnmap.size();
20739 return NULL;
20740 }
20741
20742 return ewpnmap[index].output.c_str();
20743 }
20744
20745 const char *assignplayerlist(int32_t index, int32_t *list_size)
20746 {
20747 if(index<0)
20748 {
20749 *list_size = (int32_t)playermap.size();
20750 return NULL;
20751 }
20752
20753 return playermap[index].output.c_str();
20754 }
20755
20756 const char *assigndmaplist(int32_t index, int32_t *list_size)
20757 {
20758 if(index<0)
20759 {
20760 *list_size = (int32_t)dmapmap.size();
20761 return NULL;
20762 }
20763
20764 return dmapmap[index].output.c_str();
20765 }
20766
20767 const char *assignscreenlist(int32_t index, int32_t *list_size)
20768 {
20769 if(index<0)
20770 {
20771 *list_size = (int32_t)screenmap.size();
20772 return NULL;
20773 }
20774
20775 return screenmap[index].output.c_str();
20776 }
20777
20778 const char *assignitemspritelist(int32_t index, int32_t *list_size)
20779 {
20780 if(index<0)
20781 {
20782 *list_size = (int32_t)itemspritemap.size();
20783 return NULL;
20784 }
20785
20786 return itemspritemap[index].output.c_str();
20787 }
20788
20789 const char *assignffcscriptlist(int32_t index, int32_t *list_size)
20790 {
20791 if(index<0)
20792 {
20793 *list_size = (int32_t)asffcscripts.size();
20794 return NULL;
20795 }
20796
20797 return asffcscripts[index].c_str();
20798 }
20799
20800 const char *assignglobalscriptlist(int32_t index, int32_t *list_size)
20801 {
20802 if(index<0)
20803 {
20804 *list_size = (int32_t)asglobalscripts.size();
20805 return NULL;
20806 }
20807
20808 return asglobalscripts[index].c_str();
20809 }
20810
20811 const char *assignitemscriptlist(int32_t index, int32_t *list_size)
20812 {
20813 if(index<0)
20814 {
20815 *list_size = (int32_t)asitemscripts.size();
20816 return NULL;
20817 }
20818
20819 return asitemscripts[index].c_str();
20820 }
20821
20822 const char *assignnpcscriptlist(int32_t index, int32_t *list_size)
20823 {
20824 if(index<0)
20825 {
20826 *list_size = (int32_t)asnpcscripts.size();
20827 return NULL;
20828 }
20829
20830 return asnpcscripts[index].c_str();
20831 }
20832
20833 const char *assignlweaponscriptlist(int32_t index, int32_t *list_size)
20834 {
20835 if(index<0)
20836 {
20837 *list_size = (int32_t)aslweaponscripts.size();
20838 return NULL;
20839 }
20840
20841 return aslweaponscripts[index].c_str();
20842 }
20843
20844 const char *assigneweaponscriptlist(int32_t index, int32_t *list_size)
20845 {
20846 if(index<0)
20847 {
20848 *list_size = (int32_t)aseweaponscripts.size();
20849 return NULL;
20850 }
20851
20852 return aseweaponscripts[index].c_str();
20853 }
20854
20855 const char *assignplayerscriptlist(int32_t index, int32_t *list_size)
20856 {
20857 if(index<0)
20858 {
20859 *list_size = (int32_t)asplayerscripts.size();
20860 return NULL;
20861 }
20862
20863 return asplayerscripts[index].c_str();
20864 }
20865
20866 const char *assigndmapscriptlist(int32_t index, int32_t *list_size)
20867 {
20868 if(index<0)
20869 {
20870 *list_size = (int32_t)asdmapscripts.size();
20871 return NULL;
20872 }
20873
20874 return asdmapscripts[index].c_str();
20875 }
20876
20877 const char *assignscreenscriptlist(int32_t index, int32_t *list_size)
20878 {
20879 if(index<0)
20880 {
20881 *list_size = (int32_t)asscreenscripts.size();
20882 return NULL;
20883 }
20884
20885 return asscreenscripts[index].c_str();
20886 }
20887
20888 const char *assignitemspritescriptlist(int32_t index, int32_t *list_size)
20889 {
20890 if(index<0)
20891 {
20892 *list_size = (int32_t)asitemspritescripts.size();
20893 return NULL;
20894 }
20895
20896 return asitemspritescripts[index].c_str();
20897 }
20898
20899 const char *assigncomboscriptlist(int32_t index, int32_t *list_size)
20900 {
20901 if(index<0)
20902 {
20903 *list_size = (int32_t)ascomboscripts.size();
20904 return NULL;
20905 }
20906
20907 return ascomboscripts[index].c_str();
20908 }
20909
20910 const char *assigngenericscriptlist(int32_t index, int32_t *list_size)
20911 {
20912 if(index<0)
20913 {
20914 *list_size = (int32_t)asgenericscripts.size();
20915 return NULL;
20916 }
20917
20918 return asgenericscripts[index].c_str();
20919 }
20920
20921 const char *assignsubscreenscriptlist(int32_t index, int32_t *list_size)
20922 {
20923 if(index<0)
20924 {
20925 *list_size = (int32_t)assubscreenscripts.size();
20926 return NULL;
20927 }
20928
20929 return assubscreenscripts[index].c_str();
20930 }
20931
20932 9 static ListData assignffc_list(assignffclist, &font);
20933 9 static ListData assignffcscript_list(assignffcscriptlist, &font);
20934 9 static ListData assignglobal_list(assigngloballist, &font);
20935 9 static ListData assignglobalscript_list(assignglobalscriptlist, &font);
20936 9 static ListData assignitem_list(assignitemlist, &font);
20937 9 static ListData assignitemscript_list(assignitemscriptlist, &font);
20938 9 static ListData assignnpc_list(assignnpclist, &font);
20939 9 static ListData assignnpcscript_list(assignnpcscriptlist, &font);
20940 9 static ListData assignlweapon_list(assignlweaponlist, &font);
20941 9 static ListData assignlweaponscript_list(assignlweaponscriptlist, &font);
20942 9 static ListData assigneweapon_list(assigneweaponlist, &font);
20943 9 static ListData assigneweaponscript_list(assigneweaponscriptlist, &font);
20944
20945 9 static ListData assignplayer_list(assignplayerlist, &font);
20946 9 static ListData assignplayerscript_list(assignplayerscriptlist, &font);
20947
20948 9 static ListData assigndmap_list(assigndmaplist, &font);
20949 9 static ListData assigndmapscript_list(assigndmapscriptlist, &font);
20950
20951 9 static ListData assignscreen_list(assignscreenlist, &font);
20952 9 static ListData assignscreenscript_list(assignscreenscriptlist, &font);
20953
20954 9 static ListData assignitemsprite_list(assignitemspritelist, &font);
20955 9 static ListData assignitemspritescript_list(assignitemspritescriptlist, &font);
20956
20957 9 static ListData assigncombo_list(assigncombolist, &font);
20958 9 static ListData assigncomboscript_list(assigncomboscriptlist, &font);
20959
20960 9 static ListData assigngeneric_list(assigngenericlist, &font);
20961 9 static ListData assigngenericscript_list(assigngenericscriptlist, &font);
20962
20963 9 static ListData assignsubscreen_list(assignsubscreenlist, &font);
20964 9 static ListData assignsubscreenscript_list(assignsubscreenscriptlist, &font);
20965
20966 static DIALOG assignscript_dlg[] =
20967 {
20968 // x y w h fg bg key flags d1 d2 dp
20969 9 { jwin_win_proc, 0, 0, 330, 236, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Assign Compiled Script", NULL, NULL },
20970 9 { jwin_tab_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, (void*)assignscript_dlg },
20971 9 { jwin_button_proc, 251, 207, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
20972 9 { jwin_button_proc, 182, 207, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
20973 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffc_list, NULL, NULL },
20974 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffcscript_list, NULL, NULL },
20975 //6
20976 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
20977 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobal_list, NULL, NULL },
20978 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobalscript_list, NULL, NULL },
20979 //9
20980 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
20981 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitem_list, NULL, NULL },
20982 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemscript_list, NULL, NULL },
20983 //12
20984 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
20985 //13
20986 9 { jwin_check_proc, 22, 211, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Output ZASM code to allegro.log", NULL, NULL },
20987 9 { jwin_text_proc, 22, 178, 90, 24, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
20988 9 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
20989 //16
20990 9 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
20991 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
20992 //npc scripts
20993 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpc_list, NULL, NULL },
20994 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpcscript_list, NULL, NULL },
20995 //20
20996 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
20997 //21
20998 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweapon_list, NULL, NULL },
20999 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweaponscript_list, NULL, NULL },
21000 //23
21001 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21002 //24
21003 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweapon_list, NULL, NULL },
21004 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweaponscript_list, NULL, NULL },
21005 //26
21006 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21007 //27
21008 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayer_list, NULL, NULL },
21009 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayerscript_list, NULL, NULL },
21010 //29
21011 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21012 //30
21013 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreen_list, NULL, NULL },
21014 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreenscript_list, NULL, NULL },
21015 //32
21016 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21017 //33
21018 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmap_list, NULL, NULL },
21019 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmapscript_list, NULL, NULL },
21020 //35
21021 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21022 //36
21023 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemsprite_list, NULL, NULL },
21024 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemspritescript_list, NULL, NULL },
21025 //38
21026 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21027
21028 //39
21029 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncombo_list, NULL, NULL },
21030 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncomboscript_list, NULL, NULL },
21031 //41
21032 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21033 9 { jwin_button_proc, 78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
21034 9 { jwin_button_proc, 174+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
21035 9 { jwin_button_proc, 87+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear", NULL, NULL },
21036 //45
21037 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngeneric_list, NULL, NULL },
21038 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngenericscript_list, NULL, NULL },
21039 //47
21040 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21041 //48
21042 9 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreen_list, NULL, NULL },
21043 9 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreenscript_list, NULL, NULL },
21044 //50
21045 9 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
21046 9 { jwin_check_proc, 22, 221, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "...And output ZASM comments", NULL, NULL },
21047
21048 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21049
21050 };
21051
21052 int32_t txtout(BITMAP* dest, const char* txt, int32_t x, int32_t y, bool disabled)
21053 {
21054 if(disabled)
21055 {
21056 gui_textout_ln(dest, font, (uint8_t*)txt, x+1, y+1, scheme[jcLIGHT], scheme[jcBOX], 0);
21057 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcMEDDARK], -1, 0);
21058 }
21059 else
21060 {
21061 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcBOXFG], scheme[jcBOX], 0);
21062 }
21063 }
21064
21065 int32_t jwin_zmeta_proc(int32_t msg, DIALOG *d, int32_t )
21066 {
21067 int32_t ret = D_O_K;
21068 ASSERT(d);
21069
21070 BITMAP* target = (msg==MSG_START ? NULL : screen);
21071 switch(msg)
21072 {
21073 case MSG_START:
21074 case MSG_DRAW:
21075 {
21076 FONT *oldfont = font;
21077
21078 if(d->dp2)
21079 {
21080 font = (FONT*)d->dp2;
21081 }
21082
21083 bool disabled = (d->flags & D_DISABLED) != 0;
21084 if(d->dp)
21085 {
21086 zasm_meta const& meta = *((zasm_meta*)d->dp);
21087 int32_t ind = -1;
21088 d->w = 0;
21089 if(!meta.valid())
21090 {
21091 d->w = txtout(target, "Invalid ZASM metadata found!", d->x, d->y, disabled);
21092 ++ind;
21093 }
21094
21095 int32_t t_w = 0;
21096 char buf[1024];
21097 memset(buf, 0, sizeof(buf));
21098 sprintf(buf, "ZASM Version: %d", meta.zasm_v);
21099 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21100 d->w = zc_max(d->w, t_w);
21101 memset(buf, 0, sizeof(buf));
21102 sprintf(buf, "Metadata Version: %d", meta.meta_v);
21103 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21104 d->w = zc_max(d->w, t_w);
21105 memset(buf, 0, sizeof(buf));
21106 sprintf(buf, "FFScript Version: %d", meta.ffscript_v);
21107 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21108 d->w = zc_max(d->w, t_w);
21109 memset(buf, 0, sizeof(buf));
21110 sprintf(buf, "Script Name: %s", meta.script_name.c_str());
21111 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21112 d->w = zc_max(d->w, t_w);
21113 memset(buf, 0, sizeof(buf));
21114 sprintf(buf, "Author: %s", meta.author.c_str());
21115 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21116 d->w = zc_max(d->w, t_w);
21117 memset(buf, 0, sizeof(buf));
21118 sprintf(buf, "Script Type: %s", get_script_name(meta.script_type).c_str());
21119 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21120 d->w = zc_max(d->w, t_w);
21121 for(auto q = 0; q < 4; ++q)
21122 {
21123 if(!meta.attributes[q].size())
21124 continue;
21125 memset(buf, 0, sizeof(buf));
21126 sprintf(buf, "Attributes[%d]: %s", q, meta.attributes[q].c_str());
21127 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21128 d->w = zc_max(d->w, t_w);
21129 }
21130 for(auto q = 0; q < 8; ++q)
21131 {
21132 if(!meta.attribytes[q].size())
21133 continue;
21134 memset(buf, 0, sizeof(buf));
21135 sprintf(buf, "Attribytes[%d]: %s", q, meta.attribytes[q].c_str());
21136 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21137 d->w = zc_max(d->w, t_w);
21138 }
21139 for(auto q = 0; q < 8; ++q)
21140 {
21141 if(!meta.attrishorts[q].size())
21142 continue;
21143 memset(buf, 0, sizeof(buf));
21144 sprintf(buf, "Attrishorts[%d]: %s", q, meta.attrishorts[q].c_str());
21145 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21146 d->w = zc_max(d->w, t_w);
21147 }
21148 bool indentrun = false;
21149 int32_t run_indent = txtout(NULL, "void run(", 0, 0, false);
21150 std::ostringstream oss;
21151 oss << "void run(";
21152 for(int32_t q = 0; q < 8; ++q)
21153 {
21154 if(!meta.run_idens[q].size() || meta.run_types[q] == ZMETA_NULL_TYPE) continue;
21155 if(q > 0)
21156 oss << ", ";
21157 string type_name = ZScript::getDataTypeName(meta.run_types[q]);
21158 lowerstr(type_name); //all lowercase for this output
21159 if(oss.str().size() > unsigned(indentrun ? 41 : 50))
21160 {
21161 memset(buf, 0, sizeof(buf));
21162 sprintf(buf, "%s", oss.str().c_str());
21163 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
21164 d->w = zc_max(d->w, t_w);
21165 oss.str("");
21166 indentrun = true;
21167 }
21168 oss << type_name.c_str() << " " << meta.run_idens[q];
21169 }
21170 oss << ");";
21171 memset(buf, 0, sizeof(buf));
21172 sprintf(buf, "%s", oss.str().c_str());
21173 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
21174 d->w = zc_max(d->w, t_w);
21175 memset(buf, 0, sizeof(buf));
21176 sprintf(buf, "Compiler Version: %d.%d.%d.%d", meta.compiler_v1, meta.compiler_v2, meta.compiler_v3, meta.compiler_v4);
21177 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21178 d->w = zc_max(d->w, t_w);
21179 memset(buf, 0, sizeof(buf));
21180 sprintf(buf, "Parser-generated: %s", (meta.flags & ZMETA_AUTOGEN)!=0 ? "TRUE" : "FALSE");
21181 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
21182 d->w = zc_max(d->w, t_w);
21183 d->h = (++ind) * (text_height(font) + 3) -3;
21184 }
21185 else
21186 {
21187 d->w = txtout(target, "No ZASM metadata found!", d->x, d->y, disabled);
21188 d->h = text_height(font);
21189 }
21190
21191 if(d->dp3) //function trigger
21192 {
21193 typedef void (*funcType)(void);
21194 funcType func=reinterpret_cast<funcType>(d->dp3);
21195 func();
21196 }
21197
21198 font = oldfont;
21199 break;
21200 }
21201 }
21202
21203 return ret;
21204 }
21205
21206 void resize_scriptinfo_dlg();
21207
21208 static DIALOG scriptinfo_dlg[] =
21209 {
21210 // x y w h fg bg key flags d1 d2 dp
21211 { jwin_win_proc, 0, 0, 200, 150, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Metadata", NULL, NULL },
21212 { d_dummy_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, NULL },
21213 { jwin_button_proc, 70, 120, 60, 20, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
21214 { jwin_zmeta_proc, 50, 30, 100, 100, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, (void*)resize_scriptinfo_dlg },
21215
21216 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21217 };
21218
21219 void resize_scriptinfo_dlg()
21220 {
21221 DIALOG *meta_proc = &scriptinfo_dlg[3], *window = &scriptinfo_dlg[0], *ok_button = &scriptinfo_dlg[2];
21222 int32_t bmargin = 15, hmargins = 30;
21223 jwin_ulalign_dialog(scriptinfo_dlg);
21224 window->w = hmargins*2 + meta_proc->w;
21225 meta_proc->x = hmargins;
21226 window->h = meta_proc->y + meta_proc->h + ok_button->h + bmargin*2;
21227 ok_button->x = (window->w/2)-(ok_button->w/2);
21228 ok_button->y = meta_proc->y + meta_proc->h + bmargin;
21229 jwin_center_dialog(scriptinfo_dlg);
21230 }
21231
21232 void showScriptInfo(zasm_meta const* meta)
21233 {
21234 scriptinfo_dlg[3].dp = (void*)meta;
21235 scriptinfo_dlg[0].dp2 = get_zc_font(font_lfont);
21236 large_dialog(scriptinfo_dlg);
21237 jwin_zmeta_proc(MSG_START,&scriptinfo_dlg[3],0); //Calculate size before calling dialog
21238 jwin_center_dialog(scriptinfo_dlg);
21239 do_zqdialog(scriptinfo_dlg,2);
21240 }
21241
21242 void write_includepaths();
21243 void call_compile_settings();
21244 int32_t onZScriptCompilerSettings()
21245 {
21246 call_compile_settings();
21247 return D_O_K;
21248 }
21249
21250 void doEditZScript()
21251 {
21252 if(do_box_edit(zScript, "ZScript Buffer", false, false))
21253 saved=false;
21254 }
21255
21256 std::string qst_cfg_header_from_path(std::string path);
21257 extern char *filepath;
21258 string get_box_cfg_hdr(int num)
21259 {
21260 if(num)
21261 return "misc";
21262 return qst_cfg_header_from_path(filepath);
21263 }
21264
21265 //{ Start type-specific import dlgs
21266 9 static ListData ffscript_sel_dlg_list(ffscriptlist2, &font);
21267 9 static ListData itemscript_sel_dlg_list(itemscriptlist2, &font);
21268 9 static ListData comboscript_sel_dlg_list(comboscriptlist2, &font);
21269 9 static ListData gscript_sel_dlg_list(gscriptlist2, &font);
21270 static char npcscript_str_buf2[32];
21271 const char *npcscriptlist2(int32_t index, int32_t *list_size)
21272 {
21273 if(index>=0)
21274 {
21275 char buf[20];
21276 bound(index,0,254);
21277
21278 if(npcmap[index].scriptname=="")
21279 strcpy(buf, "<none>");
21280 else
21281 {
21282 strncpy(buf, npcmap[index].scriptname.c_str(), 19);
21283 buf[19]='\0';
21284 }
21285
21286 sprintf(npcscript_str_buf2,"%d: %s",index+1, buf);
21287 return npcscript_str_buf2;
21288 }
21289
21290 *list_size=(NUMSCRIPTGUYS-1);
21291 return NULL;
21292 }
21293 9 static ListData npcscript_sel_dlg_list(npcscriptlist2, &font);
21294 static char lweaponscript_str_buf2[32];
21295 const char *lweaponscriptlist2(int32_t index, int32_t *list_size)
21296 {
21297 if(index>=0)
21298 {
21299 char buf[20];
21300 bound(index,0,254);
21301
21302 if(lwpnmap[index].scriptname=="")
21303 strcpy(buf, "<none>");
21304 else
21305 {
21306 strncpy(buf, lwpnmap[index].scriptname.c_str(), 19);
21307 buf[19]='\0';
21308 }
21309
21310 sprintf(lweaponscript_str_buf2,"%d: %s",index+1, buf);
21311 return lweaponscript_str_buf2;
21312 }
21313
21314 *list_size=(NUMSCRIPTWEAPONS-1);
21315 return NULL;
21316 }
21317 9 static ListData lweaponscript_sel_dlg_list(lweaponscriptlist2, &font);
21318 static char eweaponscript_str_buf2[32];
21319 const char *eweaponscriptlist2(int32_t index, int32_t *list_size)
21320 {
21321 if(index>=0)
21322 {
21323 char buf[20];
21324 bound(index,0,254);
21325
21326 if(ewpnmap[index].scriptname=="")
21327 strcpy(buf, "<none>");
21328 else
21329 {
21330 strncpy(buf, ewpnmap[index].scriptname.c_str(), 19);
21331 buf[19]='\0';
21332 }
21333
21334 sprintf(eweaponscript_str_buf2,"%d: %s",index+1, buf);
21335 return eweaponscript_str_buf2;
21336 }
21337
21338 *list_size=(NUMSCRIPTWEAPONS-1);
21339 return NULL;
21340 }
21341 9 static ListData eweaponscript_sel_dlg_list(eweaponscriptlist2, &font);
21342 static char playerscript_str_buf2[32];
21343 const char *playerscriptlist2(int32_t index, int32_t *list_size)
21344 {
21345 if(index>=0)
21346 {
21347 char buf[20];
21348 bound(index,0,3);
21349
21350 if(playermap[index].scriptname=="")
21351 strcpy(buf, "<none>");
21352 else
21353 {
21354 strncpy(buf, playermap[index].scriptname.c_str(), 19);
21355 buf[19]='\0';
21356 }
21357
21358 if(index==0)
21359 sprintf(playerscript_str_buf2,"Init: %s", buf);
21360
21361 if(index==1)
21362 sprintf(playerscript_str_buf2,"Active: %s", buf);
21363
21364 if(index==2)
21365 sprintf(playerscript_str_buf2,"Death: %s", buf);
21366
21367
21368 //sprintf(playerscript_str_buf2,"%d: %s",index+1, buf);
21369 return playerscript_str_buf2;
21370 }
21371
21372 *list_size=(NUMSCRIPTPLAYER-1);
21373 return NULL;
21374 }
21375 static char itemspritescript_str_buf2[32];
21376 const char *itemspritescriptlist2(int32_t index, int32_t *list_size)
21377 {
21378 if(index>=0)
21379 {
21380 char buf[20];
21381 bound(index,0,254);
21382
21383 if(itemspritemap[index].scriptname=="")
21384 strcpy(buf, "<none>");
21385 else
21386 {
21387 strncpy(buf, itemspritemap[index].scriptname.c_str(), 19);
21388 buf[19]='\0';
21389 }
21390
21391 sprintf(itemspritescript_str_buf2,"%d: %s",index+1, buf);
21392 return itemspritescript_str_buf2;
21393 }
21394
21395 *list_size=(NUMSCRIPTSITEMSPRITE-1);
21396 return NULL;
21397 }
21398 9 static ListData playerscript_sel_dlg_list(playerscriptlist2, &font);
21399 static char dmapscript_str_buf2[32];
21400 const char *dmapscriptlist2(int32_t index, int32_t *list_size)
21401 {
21402 if(index>=0)
21403 {
21404 char buf[20];
21405 bound(index,0,254);
21406
21407 if(dmapmap[index].scriptname=="")
21408 strcpy(buf, "<none>");
21409 else
21410 {
21411 strncpy(buf, dmapmap[index].scriptname.c_str(), 19);
21412 buf[19]='\0';
21413 }
21414
21415 sprintf(dmapscript_str_buf2,"%d: %s",index+1, buf);
21416 return dmapscript_str_buf2;
21417 }
21418
21419 *list_size=(NUMSCRIPTSDMAP-1);
21420 return NULL;
21421 }
21422 9 static ListData dmapscript_sel_dlg_list(dmapscriptlist2, &font);
21423 9 static ListData itemspritescript_sel_dlg_list(itemspritescriptlist2, &font);
21424 static char screenscript_str_buf2[32];
21425 const char *screenscriptlist2(int32_t index, int32_t *list_size)
21426 {
21427 if(index>=0)
21428 {
21429 char buf[20];
21430 bound(index,0,254);
21431
21432 if(screenmap[index].scriptname=="")
21433 strcpy(buf, "<none>");
21434 else
21435 {
21436 strncpy(buf, screenmap[index].scriptname.c_str(), 19);
21437 buf[19]='\0';
21438 }
21439
21440 sprintf(screenscript_str_buf2,"%d: %s",index+1, buf);
21441 return screenscript_str_buf2;
21442 }
21443
21444 *list_size=(NUMSCRIPTSCREEN-1);
21445 return NULL;
21446 }
21447 9 static ListData screenscript_sel_dlg_list(screenscriptlist2, &font);
21448 //} End type-specific import dlgs
21449
21450 4 void clear_map_states()
21451 {
21452
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(map<int32_t, script_slot_data>::iterator it = ffcmap.begin();
21453 2048 it != ffcmap.end(); ++it)
21454 {
21455 2044 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21456 2044 }
21457
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(map<int32_t, script_slot_data>::iterator it = globalmap.begin();
21458 36 it != globalmap.end(); ++it)
21459 {
21460 32 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21461 32 }
21462
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = itemmap.begin();
21463 1024 it != itemmap.end(); ++it)
21464 {
21465 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21466 1020 }
21467
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = npcmap.begin();
21468 1024 it != npcmap.end(); ++it)
21469 {
21470 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21471 1020 }
21472
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = ewpnmap.begin();
21473 1024 it != ewpnmap.end(); ++it)
21474 {
21475 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21476 1020 }
21477
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = lwpnmap.begin();
21478 1024 it != lwpnmap.end(); ++it)
21479 {
21480 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21481 1020 }
21482
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(map<int32_t, script_slot_data>::iterator it = playermap.begin();
21483 20 it != playermap.end(); ++it)
21484 {
21485 16 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21486 16 }
21487
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = dmapmap.begin();
21488 1024 it != dmapmap.end(); ++it)
21489 {
21490 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21491 1020 }
21492
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = screenmap.begin();
21493 1024 it != screenmap.end(); ++it)
21494 {
21495 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21496 1020 }
21497
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(map<int32_t, script_slot_data>::iterator it = itemspritemap.begin();
21498 1024 it != itemspritemap.end(); ++it)
21499 {
21500 1020 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21501 1020 }
21502
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(map<int32_t, script_slot_data>::iterator it = comboscriptmap.begin();
21503 2048 it != comboscriptmap.end(); ++it)
21504 {
21505 2044 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
21506 2044 }
21507 4 }
21508
21509 4 void clearAssignSlotDlg()
21510 {
21511 4 assignscript_dlg[0].dp2 = get_zc_font(font_lfont);
21512 4 assignscript_dlg[4].d1 = -1;
21513 4 assignscript_dlg[5].d1 = -1;
21514 4 assignscript_dlg[7].d1 = -1;
21515 4 assignscript_dlg[8].d1 = -1;
21516 4 assignscript_dlg[10].d1 = -1;
21517 4 assignscript_dlg[11].d1 = -1;
21518 4 assignscript_dlg[13].flags = 0;
21519 4 }
21520
21521 int32_t onSlotAssign()
21522 {
21523 clearAssignSlotDlg();
21524 //Clear right-hand side of names
21525 asffcscripts.clear();
21526 asffcscripts.push_back("<none>");
21527 asglobalscripts.clear();
21528 asglobalscripts.push_back("<none>");
21529 asitemscripts.clear();
21530 asitemscripts.push_back("<none>");
21531 asnpcscripts.clear();
21532 asnpcscripts.push_back("<none>");
21533 aseweaponscripts.clear();
21534 aseweaponscripts.push_back("<none>");
21535 aslweaponscripts.clear();
21536 aslweaponscripts.push_back("<none>");
21537 asplayerscripts.clear();
21538 asplayerscripts.push_back("<none>");
21539 asdmapscripts.clear();
21540 asdmapscripts.push_back("<none>");
21541 asscreenscripts.clear();
21542 asscreenscripts.push_back("<none>");
21543 asitemspritescripts.clear();
21544 asitemspritescripts.push_back("<none>");
21545
21546 ascomboscripts.clear();
21547 ascomboscripts.push_back("<none>");
21548 asgenericscripts.clear();
21549 asgenericscripts.push_back("<none>");
21550 assubscreenscripts.clear();
21551 assubscreenscripts.push_back("<none>");
21552 //Declare new script vector
21553 map<string, disassembled_script_data> scripts;
21554
21555 do_script_disassembly(scripts, false);
21556
21557 do_slots(scripts, false);
21558 return D_O_K;
21559 }
21560
21561 void inc_script_name(string& name)
21562 {
21563 size_t pos = name.find_last_not_of("0123456789");
21564 pos = name.find_first_of("0123456789",pos);
21565 std::ostringstream oss;
21566 if(pos == string::npos)
21567 {
21568 oss << name << 2;
21569 }
21570 else
21571 {
21572 int32_t val = atoi(name.substr(pos).c_str());
21573 oss << name.substr(0,pos) << val+1;
21574 }
21575 name = oss.str();
21576 }
21577
21578 4 void do_script_disassembly(map<string, disassembled_script_data>& scripts, bool fromCompile)
21579 {
21580 4 clearAssignSlotDlg();
21581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 bool skipDisassembled = fromCompile && try_recovering_missing_scripts == 0;
21582
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
21583 {
21584
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 if(scripts.find(globalmap[i].scriptname) != scripts.end())
21585 {
21586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(scripts[globalmap[i].scriptname].first.script_type != ScriptType::Global)
21587 {
21588 while(scripts.find(globalmap[i].scriptname) != scripts.end())
21589 inc_script_name(globalmap[i].scriptname);
21590 }
21591 8 else continue;
21592 }
21593
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 switch(i)
21594 {
21595 case GLOBAL_SCRIPT_INIT:
21596 {
21597 break;
21598 }
21599 default:
21600
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!globalmap[i].isEmpty())
21601 {
21602 globalmap[i].format = SCRIPT_FORMAT_INVALID;
21603 }
21604 24 }
21605 24 }
21606
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTFFC-1; ++i)
21607 {
21608
2/2
✓ Branch 0 taken 1975 times.
✓ Branch 1 taken 69 times.
2044 if(scripts.find(ffcmap[i].scriptname) != scripts.end())
21609 {
21610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(scripts[ffcmap[i].scriptname].first.script_type != ScriptType::FFC)
21611 {
21612 while(scripts.find(ffcmap[i].scriptname) != scripts.end())
21613 inc_script_name(ffcmap[i].scriptname);
21614 }
21615 69 else continue;
21616 }
21617
2/2
✓ Branch 0 taken 1971 times.
✓ Branch 1 taken 4 times.
1975 if(!ffcmap[i].isEmpty())
21618 {
21619 4 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
21620 4 }
21621 1975 }
21622
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTITEM-1; ++i)
21623 {
21624
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 12 times.
1020 if(scripts.find(itemmap[i].scriptname) != scripts.end())
21625 {
21626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(scripts[itemmap[i].scriptname].first.script_type != ScriptType::Item)
21627 {
21628 while(scripts.find(itemmap[i].scriptname) != scripts.end())
21629 inc_script_name(itemmap[i].scriptname);
21630 }
21631 12 else continue;
21632 }
21633
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!itemmap[i].isEmpty())
21634 {
21635 itemmap[i].format = SCRIPT_FORMAT_INVALID;
21636 }
21637 1008 }
21638
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; ++i)
21639 {
21640
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(scripts.find(npcmap[i].scriptname) != scripts.end())
21641 {
21642 if(scripts[npcmap[i].scriptname].first.script_type != ScriptType::NPC)
21643 {
21644 while(scripts.find(npcmap[i].scriptname) != scripts.end())
21645 inc_script_name(npcmap[i].scriptname);
21646 }
21647 else continue;
21648 }
21649
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(!npcmap[i].isEmpty())
21650 {
21651 npcmap[i].format = SCRIPT_FORMAT_INVALID;
21652 }
21653 1020 }
21654
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; ++i)
21655 {
21656
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
21657 {
21658 if(scripts[lwpnmap[i].scriptname].first.script_type != ScriptType::Lwpn)
21659 {
21660 while(scripts.find(lwpnmap[i].scriptname) != scripts.end())
21661 inc_script_name(lwpnmap[i].scriptname);
21662 }
21663 else continue;
21664 }
21665
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(!lwpnmap[i].isEmpty())
21666 {
21667 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
21668 }
21669 1020 }
21670
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; ++i)
21671 {
21672
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
21673 {
21674 if(scripts[ewpnmap[i].scriptname].first.script_type != ScriptType::Ewpn)
21675 {
21676 while(scripts.find(ewpnmap[i].scriptname) != scripts.end())
21677 inc_script_name(ewpnmap[i].scriptname);
21678 }
21679 else continue;
21680 }
21681
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(!ewpnmap[i].isEmpty())
21682 {
21683 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
21684 }
21685 1020 }
21686
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i = 0; i < NUMSCRIPTPLAYER-1; ++i)
21687 {
21688
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(scripts.find(playermap[i].scriptname) != scripts.end())
21689 {
21690 if(scripts[playermap[i].scriptname].first.script_type != ScriptType::Player)
21691 {
21692 while(scripts.find(playermap[i].scriptname) != scripts.end())
21693 inc_script_name(playermap[i].scriptname);
21694 }
21695 else continue;
21696 }
21697
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!playermap[i].isEmpty())
21698 {
21699 playermap[i].format = SCRIPT_FORMAT_INVALID;
21700 }
21701 16 }
21702
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; ++i)
21703 {
21704
2/2
✓ Branch 0 taken 1018 times.
✓ Branch 1 taken 2 times.
1020 if(scripts.find(dmapmap[i].scriptname) != scripts.end())
21705 {
21706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(scripts[dmapmap[i].scriptname].first.script_type != ScriptType::DMap)
21707 {
21708 while(scripts.find(dmapmap[i].scriptname) != scripts.end())
21709 inc_script_name(dmapmap[i].scriptname);
21710 }
21711 2 else continue;
21712 }
21713
1/2
✓ Branch 0 taken 1018 times.
✗ Branch 1 not taken.
1018 if(!dmapmap[i].isEmpty())
21714 {
21715 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
21716 }
21717 1018 }
21718
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; ++i)
21719 {
21720
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 1 times.
1020 if(scripts.find(screenmap[i].scriptname) != scripts.end())
21721 {
21722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(scripts[screenmap[i].scriptname].first.script_type != ScriptType::Screen)
21723 {
21724 while(scripts.find(screenmap[i].scriptname) != scripts.end())
21725 inc_script_name(screenmap[i].scriptname);
21726 }
21727 1 else continue;
21728 }
21729
1/2
✓ Branch 0 taken 1019 times.
✗ Branch 1 not taken.
1019 if(!screenmap[i].isEmpty())
21730 {
21731 screenmap[i].format = SCRIPT_FORMAT_INVALID;
21732 }
21733 1019 }
21734
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; ++i)
21735 {
21736
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
21737 {
21738 if(scripts[itemspritemap[i].scriptname].first.script_type != ScriptType::ItemSprite)
21739 {
21740 while(scripts.find(itemspritemap[i].scriptname) != scripts.end())
21741 inc_script_name(itemspritemap[i].scriptname);
21742 }
21743 else continue;
21744 }
21745
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(!itemspritemap[i].isEmpty())
21746 {
21747 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
21748 }
21749 1020 }
21750
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; ++i)
21751 {
21752
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
21753 {
21754 if(scripts[comboscriptmap[i].scriptname].first.script_type != ScriptType::Combo)
21755 {
21756 while(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
21757 inc_script_name(comboscriptmap[i].scriptname);
21758 }
21759 else continue;
21760 }
21761
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(!comboscriptmap[i].isEmpty())
21762 {
21763 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
21764 }
21765 2044 }
21766
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; ++i)
21767 {
21768
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(scripts.find(genericmap[i].scriptname) != scripts.end())
21769 {
21770 if(scripts[genericmap[i].scriptname].first.script_type != ScriptType::Generic)
21771 {
21772 while(scripts.find(genericmap[i].scriptname) != scripts.end())
21773 inc_script_name(genericmap[i].scriptname);
21774 }
21775 else continue;
21776 }
21777
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(!genericmap[i].isEmpty())
21778 {
21779 genericmap[i].format = SCRIPT_FORMAT_INVALID;
21780 }
21781 2044 }
21782
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1020 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; ++i)
21783 {
21784
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
21785 {
21786 if(scripts[subscreenmap[i].scriptname].first.script_type != ScriptType::EngineSubscreen)
21787 {
21788 while(scripts.find(subscreenmap[i].scriptname) != scripts.end())
21789 inc_script_name(subscreenmap[i].scriptname);
21790 }
21791 else continue;
21792 }
21793
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(!subscreenmap[i].isEmpty())
21794 {
21795 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
21796 }
21797 1020 }
21798 4 }
21799
21800 enum script_slot_type
21801 {
21802 type_ffc, type_global, type_itemdata, type_npc, type_lweapon, type_eweapon,
21803 type_hero, type_dmap, type_screen, type_itemsprite, type_combo, type_generic,
21804 type_subscreen, num_types
21805 };
21806 script_slot_type getType(ScriptType type)
21807 {
21808 switch(type)
21809 {
21810 case ScriptType::FFC: return type_ffc;
21811 case ScriptType::Global: return type_global;
21812 case ScriptType::Item: return type_itemdata;
21813 case ScriptType::NPC: return type_npc;
21814 case ScriptType::Lwpn: return type_lweapon;
21815 case ScriptType::Ewpn: return type_eweapon;
21816 case ScriptType::Player: return type_hero;
21817 case ScriptType::DMap:
21818 case ScriptType::ScriptedActiveSubscreen:
21819 case ScriptType::ScriptedPassiveSubscreen:
21820 case ScriptType::OnMap:
21821 return type_dmap;
21822 case ScriptType::Generic: case ScriptType::GenericFrozen:
21823 return type_generic;
21824 case ScriptType::Screen: return type_screen;
21825 case ScriptType::ItemSprite: return type_itemsprite;
21826 case ScriptType::Combo: return type_combo;
21827 case ScriptType::EngineSubscreen: return type_subscreen;
21828 default: return type_ffc; //Default
21829 }
21830 }
21831 #define SLOTMSGFLAG_MISSING 0x01
21832 #define SLOTMSGFLAG_PRESERVED 0x02
21833 #define SLOTMSGFLAG_IMPORTED 0x04
21834 #define SLOTMSG_SIZE 512
21835 bool checkSkip(int32_t format, byte flags)
21836 {
21837 switch(format)
21838 {
21839 case SCRIPT_FORMAT_DEFAULT:
21840 return (flags != 0);
21841 case SCRIPT_FORMAT_INVALID:
21842 return ((flags & SLOTMSGFLAG_MISSING)==0);
21843 case SCRIPT_FORMAT_DISASSEMBLED:
21844 return ((flags & SLOTMSGFLAG_PRESERVED)==0);
21845 case SCRIPT_FORMAT_ZASM:
21846 return ((flags & SLOTMSGFLAG_IMPORTED)==0);
21847 default: return true;
21848 }
21849 }
21850 void clearAllSlots(int32_t type, byte flags = 0)
21851 {
21852 bound(type,0,num_types-1);
21853 switch(type)
21854 {
21855 case type_ffc:
21856 {
21857 for(int32_t q = 0; q < NUMSCRIPTFFC-1; ++q)
21858 {
21859 if(checkSkip(ffcmap[q].format, flags)) continue;
21860 ffcmap[q].scriptname = "";
21861 ffcmap[q].format = SCRIPT_FORMAT_DEFAULT;
21862 }
21863 break;
21864 }
21865 case type_global:
21866 {
21867 //Start at 1 to not clear Init
21868 for(int32_t q = 1; q < NUMSCRIPTGLOBAL; ++q)
21869 {
21870 if(checkSkip(globalmap[q].format, flags)) continue;
21871 globalmap[q].scriptname = "";
21872 globalmap[q].format = SCRIPT_FORMAT_DEFAULT;
21873 }
21874 break;
21875 }
21876 case type_itemdata:
21877 {
21878 for(int32_t q = 0; q < NUMSCRIPTITEM-1; ++q)
21879 {
21880 if(checkSkip(itemmap[q].format, flags)) continue;
21881 itemmap[q].scriptname = "";
21882 itemmap[q].format = SCRIPT_FORMAT_DEFAULT;
21883 }
21884 break;
21885 }
21886 case type_npc:
21887 {
21888 for(int32_t q = 0; q < NUMSCRIPTGUYS-1; ++q)
21889 {
21890 if(checkSkip(npcmap[q].format, flags)) continue;
21891 npcmap[q].scriptname = "";
21892 npcmap[q].format = SCRIPT_FORMAT_DEFAULT;
21893 }
21894 break;
21895 }
21896 case type_lweapon:
21897 {
21898 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
21899 {
21900 if(checkSkip(lwpnmap[q].format, flags)) continue;
21901 lwpnmap[q].scriptname = "";
21902 lwpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
21903 }
21904 break;
21905 }
21906 case type_eweapon:
21907 {
21908 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
21909 {
21910 if(checkSkip(ewpnmap[q].format, flags)) continue;
21911 ewpnmap[q].scriptname = "";
21912 ewpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
21913 }
21914 break;
21915 }
21916 case type_hero:
21917 {
21918 for(int32_t q = 0; q < NUMSCRIPTPLAYER-1; ++q)
21919 {
21920 if(checkSkip(playermap[q].format, flags)) continue;
21921 playermap[q].scriptname = "";
21922 playermap[q].format = SCRIPT_FORMAT_DEFAULT;
21923 }
21924 break;
21925 }
21926 case type_dmap:
21927 {
21928 for(int32_t q = 0; q < NUMSCRIPTSDMAP-1; ++q)
21929 {
21930 if(checkSkip(dmapmap[q].format, flags)) continue;
21931 dmapmap[q].scriptname = "";
21932 dmapmap[q].format = SCRIPT_FORMAT_DEFAULT;
21933 }
21934 break;
21935 }
21936 case type_screen:
21937 {
21938 for(int32_t q = 0; q < NUMSCRIPTSCREEN-1; ++q)
21939 {
21940 if(checkSkip(screenmap[q].format, flags)) continue;
21941 screenmap[q].scriptname = "";
21942 screenmap[q].format = SCRIPT_FORMAT_DEFAULT;
21943 }
21944 break;
21945 }
21946 case type_itemsprite:
21947 {
21948 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE-1; ++q)
21949 {
21950 if(checkSkip(itemspritemap[q].format, flags)) continue;
21951 itemspritemap[q].scriptname = "";
21952 itemspritemap[q].format = SCRIPT_FORMAT_DEFAULT;
21953 }
21954 break;
21955 }
21956 case type_combo:
21957 {
21958 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA-1; ++q)
21959 {
21960 if(checkSkip(comboscriptmap[q].format, flags)) continue;
21961 comboscriptmap[q].scriptname = "";
21962 comboscriptmap[q].format = SCRIPT_FORMAT_DEFAULT;
21963 }
21964 break;
21965 }
21966 case type_generic:
21967 {
21968 for(int32_t q = 0; q < NUMSCRIPTSGENERIC-1; ++q)
21969 {
21970 if(checkSkip(genericmap[q].format, flags)) continue;
21971 genericmap[q].scriptname = "";
21972 genericmap[q].format = SCRIPT_FORMAT_DEFAULT;
21973 }
21974 break;
21975 }
21976 case type_subscreen:
21977 {
21978 for(int32_t q = 0; q < NUMSCRIPTSSUBSCREEN-1; ++q)
21979 {
21980 if(checkSkip(subscreenmap[q].format, flags)) continue;
21981 subscreenmap[q].scriptname = "";
21982 subscreenmap[q].format = SCRIPT_FORMAT_DEFAULT;
21983 }
21984 break;
21985 }
21986 }
21987 }
21988
21989 static bool doslots_log_output = false, doslots_comment_output = true;
21990 4 void setup_scriptslot_dlg(char* buf, byte flags)
21991 {
21992 //{ Set up the textbox at the bottom, and auto-resize height based on it
21993 4 int32_t prev_height = assignscript_dlg[14].h;
21994 4 memset(buf, 0, SLOTMSG_SIZE);
21995 //
21996 4 strcpy(buf, "Slots with matching names have been updated.\n");
21997
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(flags & SLOTMSGFLAG_MISSING)
21998 2 strcat(buf,"Scripts prefixed with '--' were not found, and will not function.\n");
21999
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(flags & SLOTMSGFLAG_PRESERVED)
22000 strcat(buf, "Scripts prefixed with '++' were not found, but have been preserved.\n"
22001 " These scripts may not function correctly if they use global variables.\n");
22002
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(flags & SLOTMSGFLAG_IMPORTED)
22003 strcat(buf,"Scripts prefixed with '==' are imported ZASM scripts.\n");
22004 4 strcat(buf,"Global scripts named 'Init' will be appended to '~Init'");
22005 //
22006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 SETFLAG(assignscript_dlg[13].flags, D_SELECTED, doslots_log_output);
22007
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 SETFLAG(assignscript_dlg[51].flags, D_SELECTED, doslots_comment_output);
22008 4 assignscript_dlg[14].dp = buf;
22009 4 object_message(&assignscript_dlg[14], MSG_START, 0); //Set the width/height
22010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(int32_t diff = assignscript_dlg[14].h - prev_height) //resize dlg
22011 {
22012 4 int32_t prev_bottom = assignscript_dlg[14].y + prev_height;
22013
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 4 times.
208 for(int32_t q = 1; assignscript_dlg[q].proc; ++q)
22014 {
22015
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 200 times.
204 if(q==14) continue; //Don't change self
22016
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 16 times.
200 if(assignscript_dlg[q].y < prev_bottom) continue; //above proc
22017 16 assignscript_dlg[q].y += diff;
22018 16 }
22019 4 assignscript_dlg[0].h += diff;
22020 4 jwin_center_dialog(assignscript_dlg);
22021 4 }
22022 //}
22023 4 }
22024
22025 std::string global_slotnames[NUMSCRIPTGLOBAL] = {
22026 "Init",
22027 "Active",
22028 "onExit",
22029 "onSaveLoad",
22030 "onLaunch",
22031 "onContGame",
22032 "onF6Menu",
22033 "onSave",
22034 };
22035 std::string player_slotnames[NUMSCRIPTPLAYER-1] = {
22036 "Init",
22037 "Active",
22038 "onDeath",
22039 "onWin",
22040 };
22041 4 byte reload_scripts(map<string, disassembled_script_data> &scripts)
22042 {
22043 4 byte slotflags = 0;
22044 char temp[100];
22045
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTFFC-1; i++)
22046 {
22047
2/2
✓ Branch 0 taken 1971 times.
✓ Branch 1 taken 73 times.
2044 if(ffcmap[i].isEmpty())
22048 1971 sprintf(temp, "Slot %d:", i+1);
22049 else
22050 {
22051 73 sprintf(temp, "Slot %d:", i+1);
22052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(ffcmap[i].isZASM())
22053 {
22054 if(ffcmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22055 else slotflags |= SLOTMSGFLAG_PRESERVED;
22056 }
22057
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4 times.
73 else if(scripts.find(ffcmap[i].scriptname) != scripts.end())
22058 69 ffcmap[i].format = SCRIPT_FORMAT_DEFAULT;
22059 else // Previously loaded script not found
22060 {
22061 4 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
22062 4 slotflags |= SLOTMSGFLAG_MISSING;
22063 }
22064 }
22065 2044 ffcmap[i].slotname = temp;
22066 2044 ffcmap[i].update();
22067 2044 }
22068
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; i++)
22069 {
22070
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 globalmap[i].slotname=fmt::format("{}:",global_slotnames[i]);
22071
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 if(!globalmap[i].isEmpty())
22072 {
22073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(globalmap[i].isZASM())
22074 {
22075 if(globalmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22076 else slotflags |= SLOTMSGFLAG_PRESERVED;
22077 }
22078
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 else if(scripts.find(globalmap[i].scriptname) != scripts.end() || globalmap[i].scriptname == "~Init")
22079 8 globalmap[i].format = SCRIPT_FORMAT_DEFAULT;
22080 else // Unloaded
22081 {
22082 globalmap[i].format = SCRIPT_FORMAT_INVALID;
22083 slotflags |= SLOTMSGFLAG_MISSING;
22084 }
22085 8 }
22086 32 globalmap[i].update();
22087 32 }
22088
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTITEM-1; i++)
22089 {
22090
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 12 times.
1020 if(itemmap[i].isEmpty())
22091 1008 sprintf(temp, "Slot %d:", i+1);
22092 else
22093 {
22094 12 sprintf(temp, "Slot %d:", i+1);
22095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(itemmap[i].isZASM())
22096 {
22097 if(itemmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22098 else slotflags |= SLOTMSGFLAG_PRESERVED;
22099 }
22100
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 else if(scripts.find(itemmap[i].scriptname) != scripts.end())
22101 12 itemmap[i].format = SCRIPT_FORMAT_DEFAULT;
22102 else // Previously loaded script not found
22103 {
22104 itemmap[i].format = SCRIPT_FORMAT_INVALID;
22105 slotflags |= SLOTMSGFLAG_MISSING;
22106 }
22107 }
22108 1020 itemmap[i].slotname = temp;
22109 1020 itemmap[i].update();
22110 1020 }
22111
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; i++)
22112 {
22113
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(npcmap[i].isEmpty())
22114 1020 sprintf(temp, "Slot %d:", i+1);
22115 else
22116 {
22117 sprintf(temp, "Slot %d:", i+1);
22118 if(npcmap[i].isZASM())
22119 {
22120 if(npcmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22121 else slotflags |= SLOTMSGFLAG_PRESERVED;
22122 }
22123 else if(scripts.find(npcmap[i].scriptname) != scripts.end())
22124 npcmap[i].format = SCRIPT_FORMAT_DEFAULT;
22125 else // Previously loaded script not found
22126 {
22127 npcmap[i].format = SCRIPT_FORMAT_INVALID;
22128 slotflags |= SLOTMSGFLAG_MISSING;
22129 }
22130 }
22131 1020 npcmap[i].slotname = temp;
22132 1020 npcmap[i].update();
22133 1020 }
22134
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
22135 {
22136
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(ewpnmap[i].isEmpty())
22137 1020 sprintf(temp, "Slot %d:", i+1);
22138 else
22139 {
22140 sprintf(temp, "Slot %d:", i+1);
22141 if(ewpnmap[i].isZASM())
22142 {
22143 if(ewpnmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22144 else slotflags |= SLOTMSGFLAG_PRESERVED;
22145 }
22146 else if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
22147 ewpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
22148 else // Previously loaded script not found
22149 {
22150 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
22151 slotflags |= SLOTMSGFLAG_MISSING;
22152 }
22153 }
22154 1020 ewpnmap[i].slotname = temp;
22155 1020 ewpnmap[i].update();
22156 1020 }
22157
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
22158 {
22159
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(lwpnmap[i].isEmpty())
22160 1020 sprintf(temp, "Slot %d:", i+1);
22161 else
22162 {
22163 sprintf(temp, "Slot %d:", i+1);
22164 if(lwpnmap[i].isZASM())
22165 {
22166 if(lwpnmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22167 else slotflags |= SLOTMSGFLAG_PRESERVED;
22168 }
22169 else if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
22170 lwpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
22171 else // Previously loaded script not found
22172 {
22173 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
22174 slotflags |= SLOTMSGFLAG_MISSING;
22175 }
22176 }
22177 1020 lwpnmap[i].slotname = temp;
22178 1020 lwpnmap[i].update();
22179 1020 }
22180
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i = 0; i < NUMSCRIPTPLAYER-1; i++)
22181 {
22182
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 playermap[i].slotname=fmt::format("{}:",player_slotnames[i]);
22183
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!playermap[i].isEmpty())
22184 {
22185 if(playermap[i].isZASM())
22186 {
22187 if(playermap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22188 else slotflags |= SLOTMSGFLAG_PRESERVED;
22189 }
22190 else if(scripts.find(playermap[i].scriptname) != scripts.end())
22191 playermap[i].format = SCRIPT_FORMAT_DEFAULT;
22192 else // Unloaded
22193 {
22194 playermap[i].format = SCRIPT_FORMAT_INVALID;
22195 slotflags |= SLOTMSGFLAG_MISSING;
22196 }
22197 }
22198 16 playermap[i].update();
22199 16 }
22200
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; i++)
22201 {
22202
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 1 times.
1020 if(screenmap[i].isEmpty())
22203 1019 sprintf(temp, "Slot %d:", i+1);
22204 else
22205 {
22206 1 sprintf(temp, "Slot %d:", i+1);
22207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(screenmap[i].isZASM())
22208 {
22209 if(screenmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22210 else slotflags |= SLOTMSGFLAG_PRESERVED;
22211 }
22212
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(scripts.find(screenmap[i].scriptname) != scripts.end())
22213 1 screenmap[i].format = SCRIPT_FORMAT_DEFAULT;
22214 else // Previously loaded script not found
22215 {
22216 screenmap[i].format = SCRIPT_FORMAT_INVALID;
22217 slotflags |= SLOTMSGFLAG_MISSING;
22218 }
22219 }
22220 1020 screenmap[i].slotname = temp;
22221 1020 screenmap[i].update();
22222 1020 }
22223
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; i++)
22224 {
22225
2/2
✓ Branch 0 taken 1018 times.
✓ Branch 1 taken 2 times.
1020 if(dmapmap[i].isEmpty())
22226 1018 sprintf(temp, "Slot %d:", i+1);
22227 else
22228 {
22229 2 sprintf(temp, "Slot %d:", i+1);
22230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(dmapmap[i].isZASM())
22231 {
22232 if(dmapmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22233 else slotflags |= SLOTMSGFLAG_PRESERVED;
22234 }
22235
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(scripts.find(dmapmap[i].scriptname) != scripts.end())
22236 2 dmapmap[i].format = SCRIPT_FORMAT_DEFAULT;
22237 else // Previously loaded script not found
22238 {
22239 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
22240 slotflags |= SLOTMSGFLAG_MISSING;
22241 }
22242 }
22243 1020 dmapmap[i].slotname = temp;
22244 1020 dmapmap[i].update();
22245 1020 }
22246
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; i++)
22247 {
22248
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(itemspritemap[i].isEmpty())
22249 1020 sprintf(temp, "Slot %d:", i+1);
22250 else
22251 {
22252 sprintf(temp, "Slot %d:", i+1);
22253 if(itemspritemap[i].isZASM())
22254 {
22255 if(itemspritemap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22256 else slotflags |= SLOTMSGFLAG_PRESERVED;
22257 }
22258 else if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
22259 itemspritemap[i].format = SCRIPT_FORMAT_DEFAULT;
22260 else // Previously loaded script not found
22261 {
22262 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
22263 slotflags |= SLOTMSGFLAG_MISSING;
22264 }
22265 }
22266 1020 itemspritemap[i].slotname = temp;
22267 1020 itemspritemap[i].update();
22268 1020 }
22269
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; i++)
22270 {
22271
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(comboscriptmap[i].isEmpty())
22272 2044 sprintf(temp, "Slot %d:", i+1);
22273 else
22274 {
22275 sprintf(temp, "Slot %d:", i+1);
22276 if(comboscriptmap[i].isZASM())
22277 {
22278 if(comboscriptmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22279 else slotflags |= SLOTMSGFLAG_PRESERVED;
22280 }
22281 else if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
22282 comboscriptmap[i].format = SCRIPT_FORMAT_DEFAULT;
22283 else // Previously loaded script not found
22284 {
22285 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
22286 slotflags |= SLOTMSGFLAG_MISSING;
22287 }
22288 }
22289 2044 comboscriptmap[i].slotname = temp;
22290 2044 comboscriptmap[i].update();
22291 2044 }
22292
2/2
✓ Branch 0 taken 2044 times.
✓ Branch 1 taken 4 times.
2048 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; i++)
22293 {
22294
1/2
✓ Branch 0 taken 2044 times.
✗ Branch 1 not taken.
2044 if(genericmap[i].isEmpty())
22295 2044 sprintf(temp, "Slot %d:", i+1);
22296 else
22297 {
22298 sprintf(temp, "Slot %d:", i+1);
22299 if(genericmap[i].isZASM())
22300 {
22301 if(genericmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22302 else slotflags |= SLOTMSGFLAG_PRESERVED;
22303 }
22304 else if(scripts.find(genericmap[i].scriptname) != scripts.end())
22305 genericmap[i].format = SCRIPT_FORMAT_DEFAULT;
22306 else // Previously loaded script not found
22307 {
22308 genericmap[i].format = SCRIPT_FORMAT_INVALID;
22309 slotflags |= SLOTMSGFLAG_MISSING;
22310 }
22311 }
22312 2044 genericmap[i].slotname = temp;
22313 2044 genericmap[i].update();
22314 2044 }
22315
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 4 times.
1024 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; i++)
22316 {
22317
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(subscreenmap[i].isEmpty())
22318 1020 sprintf(temp, "Slot %d:", i+1);
22319 else
22320 {
22321 sprintf(temp, "Slot %d:", i+1);
22322 if(subscreenmap[i].isZASM())
22323 {
22324 if(subscreenmap[i].isImportedZASM()) slotflags |= SLOTMSGFLAG_IMPORTED;
22325 else slotflags |= SLOTMSGFLAG_PRESERVED;
22326 }
22327 else if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
22328 subscreenmap[i].format = SCRIPT_FORMAT_DEFAULT;
22329 else // Previously loaded script not found
22330 {
22331 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
22332 slotflags |= SLOTMSGFLAG_MISSING;
22333 }
22334 }
22335 1020 subscreenmap[i].slotname = temp;
22336 1020 subscreenmap[i].update();
22337 1020 }
22338 4 return slotflags;
22339 }
22340
22341 void doClearSlots(byte* flags);
22342
22343 extern byte compile_success_sample, compile_error_sample,
22344 compile_finish_sample, compile_audio_volume;
22345 static map<string, disassembled_script_data> *doslot_scripts = nullptr;
22346 14340 bool handle_slot(script_slot_data& slotdata, int indx, script_data** scriptdata)
22347 {
22348
2/2
✓ Branch 0 taken 14248 times.
✓ Branch 1 taken 92 times.
14340 if(slotdata.hasScriptData())
22349 {
22350 92 string scriptstr;
22351
2/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
92 (*doslot_scripts)[slotdata.scriptname].write(scriptstr, doslots_log_output, false, doslots_comment_output);
22352
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 parse_script_string(scriptdata[indx],scriptstr,false);
22353
22354
2/6
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
92 if(slotdata.isDisassembled()) scriptdata[indx]->meta.setFlag(ZMETA_DISASSEMBLED);
22355
2/6
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
92 else if(slotdata.isImportedZASM()) scriptdata[indx]->meta.setFlag(ZMETA_IMPORTED);
22356 92 }
22357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14248 times.
14248 else if(scriptdata[indx])
22358 {
22359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14248 times.
14248 delete scriptdata[indx];
22360 // script_data::id is not used in editor, so should be fine for now.
22361
1/2
✓ Branch 0 taken 14248 times.
✗ Branch 1 not taken.
14248 scriptdata[indx] = new script_data(ScriptType::None, 0);
22362 14248 }
22363 14340 return true;
22364 }
22365 52 bool handle_slot_map(map<int32_t, script_slot_data>& mp, int offs, script_data** scriptdata)
22366 {
22367
2/2
✓ Branch 0 taken 14340 times.
✓ Branch 1 taken 52 times.
14392 for(auto it = mp.begin(); it != mp.end(); it++)
22368 {
22369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14340 times.
14340 if(!handle_slot(it->second, it->first+offs, scriptdata))
22370 return false;
22371 14340 }
22372 52 return true;
22373 52 }
22374
22375 void smart_slot_named(map<string, disassembled_script_data> &scripts,
22376 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
22377 std::string* slotnames, int slotstart, int slotend)
22378 {
22379 for(int q = slotstart; q < slotend; ++q)
22380 {
22381 auto& lval = mp[q];
22382 if(!lval.isEmpty())
22383 continue; //occupied, leave alone
22384 bool done = false;
22385 if(!done) //Check case-sensitive
22386 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22387 {
22388 auto const& rval = scriptnames[rind];
22389 if(rval == "<none>") continue;
22390 if(rval == slotnames[q])
22391 { //Perfect match
22392 lval.updateName(rval);
22393 lval.format = scripts[lval.scriptname].format;
22394 done = true;
22395 break;
22396 }
22397 }
22398 if(!done) //Check case-insensitive
22399 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22400 {
22401 auto const& rval = scriptnames[rind];
22402 if(rval == "<none>") continue;
22403 string lc_rv = rval, lc_slot = slotnames[q];
22404 lowerstr(lc_rv);
22405 lowerstr(lc_slot);
22406 if(lc_rv == lc_slot)
22407 { //Insensitive match
22408 lval.updateName(rval);
22409 lval.format = scripts[lval.scriptname].format;
22410 break;
22411 }
22412 }
22413 }
22414 }
22415 void smart_slot_type(map<string, disassembled_script_data> &scripts,
22416 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
22417 int slotcount)
22418 {
22419 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
22420 {
22421 auto const& rval = scriptnames[rind];
22422 if(rval == "<none>") continue;
22423 script_slot_data* first_open_slot = nullptr;
22424 bool done = false;
22425 for(int q = 0; q < slotcount; ++q)
22426 {
22427 auto& lval = mp[q];
22428 if(lval.isEmpty())
22429 {
22430 if(!first_open_slot)
22431 first_open_slot = &lval;
22432 }
22433 else if(lval.scriptname == rval)
22434 {
22435 done = true;
22436 break;
22437 }
22438 }
22439 if(!done)
22440 {
22441 if(!first_open_slot)
22442 break; //no slots left to assign to!
22443 first_open_slot->updateName(rval);
22444 first_open_slot->format = scripts[first_open_slot->scriptname].format;
22445 }
22446 }
22447 }
22448
22449 4 bool do_slots(map<string, disassembled_script_data> &scripts, int assign_mode)
22450 {
22451 4 large_dialog(assignscript_dlg);
22452 4 int32_t ret = 3;
22453 4 char slots_msg[SLOTMSG_SIZE] = {0};
22454 4 byte slotflags = reload_scripts(scripts);
22455 4 setup_scriptslot_dlg(slots_msg, slotflags);
22456 4 bool retval = false;
22457
22458 4 popup_zqdialog_start();
22459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 while(!assign_mode)
22460 {
22461 slotflags = reload_scripts(scripts);
22462 ret = do_zqdialog(assignscript_dlg, ret);
22463
22464 switch(ret)
22465 {
22466 case 0:
22467 case 2:
22468 //Cancel
22469 goto exit_do_slots;
22470
22471 case 3: goto auto_do_slots;
22472
22473 case 6:
22474 //<<, FFC
22475 {
22476 int32_t lind = assignscript_dlg[4].d1;
22477 int32_t rind = assignscript_dlg[5].d1;
22478
22479 if(lind < 0 || rind < 0)
22480 break;
22481
22482 if(asffcscripts[rind] == "<none>")
22483 {
22484 ffcmap[lind].scriptname = "";
22485 ffcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22486 }
22487 else
22488 {
22489 ffcmap[lind].updateName(asffcscripts[rind]);
22490 ffcmap[lind].format = scripts[ffcmap[lind].scriptname].format;
22491 }
22492
22493 break;
22494 }
22495 case 9:
22496 //<<, Global
22497 {
22498 int32_t lind = assignscript_dlg[7].d1;
22499 int32_t rind = assignscript_dlg[8].d1;
22500
22501 if(lind < 0 || rind < 0)
22502 break;
22503
22504 if(lind == 0)
22505 {
22506 jwin_alert("Error","ZScript reserves this slot.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
22507 break;
22508 }
22509
22510 if(asglobalscripts[rind] == "<none>")
22511 {
22512 globalmap[lind].scriptname = "";
22513 globalmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22514 }
22515 else
22516 {
22517 globalmap[lind].updateName(asglobalscripts[rind]);
22518 globalmap[lind].format = scripts[globalmap[lind].scriptname].format;
22519 }
22520
22521 break;
22522 }
22523 case 12:
22524 //<<, ITEM
22525 {
22526 int32_t lind = assignscript_dlg[10].d1;
22527 int32_t rind = assignscript_dlg[11].d1;
22528
22529 if(lind < 0 || rind < 0)
22530 break;
22531
22532 if(asitemscripts[rind] == "<none>")
22533 {
22534 itemmap[lind].scriptname = "";
22535 itemmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22536 }
22537 else
22538 {
22539 itemmap[lind].updateName(asitemscripts[rind]);
22540 itemmap[lind].format = scripts[itemmap[lind].scriptname].format;
22541 }
22542
22543 break;
22544 }
22545 case 20:
22546 //<<, NPC
22547 {
22548 int32_t lind = assignscript_dlg[18].d1;
22549 int32_t rind = assignscript_dlg[19].d1;
22550
22551 if(lind < 0 || rind < 0)
22552 break;
22553
22554 if(asnpcscripts[rind] == "<none>")
22555 {
22556 npcmap[lind].scriptname = "";
22557 npcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22558 }
22559 else
22560 {
22561 npcmap[lind].updateName(asnpcscripts[rind]);
22562 npcmap[lind].format = scripts[npcmap[lind].scriptname].format;
22563 }
22564
22565 break;
22566 }
22567 case 23:
22568 //<<, LWeapon
22569 {
22570 int32_t lind = assignscript_dlg[21].d1;
22571 int32_t rind = assignscript_dlg[22].d1;
22572
22573 if(lind < 0 || rind < 0)
22574 break;
22575
22576 if(aslweaponscripts[rind] == "<none>")
22577 {
22578 lwpnmap[lind].scriptname = "";
22579 lwpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22580 }
22581 else
22582 {
22583 lwpnmap[lind].updateName(aslweaponscripts[rind]);
22584 lwpnmap[lind].format = scripts[lwpnmap[lind].scriptname].format;
22585 }
22586
22587 break;
22588 }
22589 case 26:
22590 //<<, EWeapon
22591 {
22592 int32_t lind = assignscript_dlg[24].d1;
22593 int32_t rind = assignscript_dlg[25].d1;
22594
22595 if(lind < 0 || rind < 0)
22596 break;
22597
22598 if(aseweaponscripts[rind] == "<none>")
22599 {
22600 ewpnmap[lind].scriptname = "";
22601 ewpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22602 }
22603 else
22604 {
22605 ewpnmap[lind].updateName(aseweaponscripts[rind]);
22606 ewpnmap[lind].format = scripts[ewpnmap[lind].scriptname].format;
22607 }
22608
22609 break;
22610 }
22611 case 29:
22612 //<<, Player
22613 {
22614 int32_t lind = assignscript_dlg[27].d1;
22615 int32_t rind = assignscript_dlg[28].d1;
22616
22617 if(lind < 0 || rind < 0)
22618 break;
22619
22620 if(asplayerscripts[rind] == "<none>")
22621 {
22622 playermap[lind].scriptname = "";
22623 playermap[lind].format = SCRIPT_FORMAT_DEFAULT;
22624 }
22625 else
22626 {
22627 playermap[lind].updateName(asplayerscripts[rind]);
22628 playermap[lind].format = scripts[playermap[lind].scriptname].format;
22629 }
22630
22631 break;
22632 }
22633 case 32:
22634 //<<, Screendata
22635 {
22636 int32_t lind = assignscript_dlg[30].d1;
22637 int32_t rind = assignscript_dlg[31].d1;
22638
22639 if(lind < 0 || rind < 0)
22640 break;
22641
22642 if(asscreenscripts[rind] == "<none>")
22643 {
22644 screenmap[lind].scriptname = "";
22645 screenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22646 }
22647 else
22648 {
22649 screenmap[lind].updateName(asscreenscripts[rind]);
22650 screenmap[lind].format = scripts[screenmap[lind].scriptname].format;
22651 }
22652
22653 break;
22654 }
22655 case 35:
22656 //<<, dmapdata
22657 {
22658 int32_t lind = assignscript_dlg[33].d1;
22659 int32_t rind = assignscript_dlg[34].d1;
22660
22661 if(lind < 0 || rind < 0)
22662 break;
22663
22664 if(asdmapscripts[rind] == "<none>")
22665 {
22666 dmapmap[lind].scriptname = "";
22667 dmapmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22668 }
22669 else
22670 {
22671 dmapmap[lind].updateName(asdmapscripts[rind]);
22672 dmapmap[lind].format = scripts[dmapmap[lind].scriptname].format;
22673 }
22674
22675 break;
22676 }
22677 case 38:
22678 //<<, itemsprite
22679 {
22680 int32_t lind = assignscript_dlg[36].d1;
22681 int32_t rind = assignscript_dlg[37].d1;
22682
22683 if(lind < 0 || rind < 0)
22684 break;
22685
22686 if(asitemspritescripts[rind] == "<none>")
22687 {
22688 itemspritemap[lind].scriptname = "";
22689 itemspritemap[lind].format = SCRIPT_FORMAT_DEFAULT;
22690 }
22691 else
22692 {
22693 itemspritemap[lind].updateName(asitemspritescripts[rind]);
22694 itemspritemap[lind].format = scripts[itemspritemap[lind].scriptname].format;
22695 }
22696
22697 break;
22698 }
22699 case 41:
22700 //<<, comboscript
22701 {
22702 int32_t lind = assignscript_dlg[39].d1;
22703 int32_t rind = assignscript_dlg[40].d1;
22704
22705 if(lind < 0 || rind < 0)
22706 break;
22707
22708 if(ascomboscripts[rind] == "<none>")
22709 {
22710 comboscriptmap[lind].scriptname = "";
22711 comboscriptmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22712 }
22713 else
22714 {
22715 comboscriptmap[lind].updateName(ascomboscripts[rind]);
22716 comboscriptmap[lind].format = scripts[comboscriptmap[lind].scriptname].format;
22717 }
22718
22719 break;
22720 }
22721 case 47:
22722 //<<, generic script
22723 {
22724 int32_t lind = assignscript_dlg[45].d1;
22725 int32_t rind = assignscript_dlg[46].d1;
22726
22727 if(lind < 0 || rind < 0)
22728 break;
22729
22730 if(asgenericscripts[rind] == "<none>")
22731 {
22732 genericmap[lind].scriptname = "";
22733 genericmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22734 }
22735 else
22736 {
22737 genericmap[lind].updateName(asgenericscripts[rind]);
22738 genericmap[lind].format = scripts[genericmap[lind].scriptname].format;
22739 }
22740
22741 break;
22742 }
22743 case 50:
22744 //<<, subscreen script
22745 {
22746 int32_t lind = assignscript_dlg[48].d1;
22747 int32_t rind = assignscript_dlg[49].d1;
22748
22749 if(lind < 0 || rind < 0)
22750 break;
22751
22752 if(assubscreenscripts[rind] == "<none>")
22753 {
22754 subscreenmap[lind].scriptname = "";
22755 subscreenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
22756 }
22757 else
22758 {
22759 subscreenmap[lind].updateName(assubscreenscripts[rind]);
22760 subscreenmap[lind].format = scripts[subscreenmap[lind].scriptname].format;
22761 }
22762
22763 break;
22764 }
22765
22766 case 42:
22767 //Script Info, information
22768 {
22769 disassembled_script_data* target = nullptr;
22770 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
22771 {
22772 default:
22773 case 0: //FFC
22774 {
22775 int32_t id = assignscript_dlg[4].d1;
22776 if(id > -1 && ffcmap[id].hasScriptData())
22777 {
22778 target = &(scripts[ffcmap[id].scriptname]);
22779 }
22780 break;
22781 }
22782 case 1: //Global
22783 {
22784 int32_t id = assignscript_dlg[7].d1;
22785 if(id > -1 && globalmap[id].hasScriptData())
22786 {
22787 target = &(scripts[globalmap[id].scriptname]);
22788 }
22789 break;
22790 }
22791 case 2: //Item
22792 {
22793 int32_t id = assignscript_dlg[10].d1;
22794 if(id > -1 && itemmap[id].hasScriptData())
22795 {
22796 target = &(scripts[itemmap[id].scriptname]);
22797 }
22798 break;
22799 }
22800 case 3: //npc
22801 {
22802 int32_t id = assignscript_dlg[19].d1;
22803 if(id > -1 && npcmap[id].hasScriptData())
22804 {
22805 target = &(scripts[npcmap[id].scriptname]);
22806 }
22807 break;
22808 }
22809 case 4: //lweapon
22810 {
22811 int32_t id = assignscript_dlg[21].d1;
22812 if(id > -1 && lwpnmap[id].hasScriptData())
22813 {
22814 target = &(scripts[lwpnmap[id].scriptname]);
22815 }
22816 break;
22817 }
22818 case 5: //eweapon
22819 {
22820 int32_t id = assignscript_dlg[24].d1;
22821 if(id > -1 && ewpnmap[id].hasScriptData())
22822 {
22823 target = &(scripts[ewpnmap[id].scriptname]);
22824 }
22825 break;
22826 }
22827 case 6: //hero
22828 {
22829 int32_t id = assignscript_dlg[27].d1;
22830 if(id > -1 && playermap[id].hasScriptData())
22831 {
22832 target = &(scripts[playermap[id].scriptname]);
22833 }
22834 break;
22835 }
22836 case 7: //dmap
22837 {
22838 int32_t id = assignscript_dlg[33].d1;
22839 if(id > -1 && dmapmap[id].hasScriptData())
22840 {
22841 target = &(scripts[dmapmap[id].scriptname]);
22842 }
22843 break;
22844 }
22845 case 8: //screen
22846 {
22847 int32_t id = assignscript_dlg[30].d1;
22848 if(id > -1 && screenmap[id].hasScriptData())
22849 {
22850 target = &(scripts[screenmap[id].scriptname]);
22851 }
22852 break;
22853 }
22854 case 9: //itemsprite
22855 {
22856 int32_t id = assignscript_dlg[36].d1;
22857 if(id > -1 && itemspritemap[id].hasScriptData())
22858 {
22859 target = &(scripts[itemspritemap[id].scriptname]);
22860 }
22861 break;
22862 }
22863 case 10: //combo
22864 {
22865 int32_t id = assignscript_dlg[39].d1;
22866 if(id > -1 && comboscriptmap[id].hasScriptData())
22867 {
22868 target = &(scripts[comboscriptmap[id].scriptname]);
22869 }
22870 break;
22871 }
22872 case 11: //Generic
22873 {
22874 int32_t id = assignscript_dlg[45].d1;
22875 if(id > -1 && genericmap[id].hasScriptData())
22876 {
22877 target = &(scripts[genericmap[id].scriptname]);
22878 }
22879 break;
22880 }
22881 case 12: //Subscreen
22882 {
22883 int32_t id = assignscript_dlg[48].d1;
22884 if(id > -1 && subscreenmap[id].hasScriptData())
22885 {
22886 target = &(scripts[subscreenmap[id].scriptname]);
22887 }
22888 break;
22889 }
22890 }
22891 zasm_meta* meta = target ? &target->first : nullptr;
22892 if(devpwd() && CHECK_CTRL_CMD)
22893 {
22894 string str;
22895 target->write(str, false, false, (assignscript_dlg[51].flags == D_SELECTED), true);
22896 set_al_clipboard(str);
22897 displayinfo("Clipboard Copy","Copied ZASM of selected script to clipboard");
22898 }
22899 else if(meta)
22900 showScriptInfo(meta);
22901 break;
22902 }
22903
22904 case 43:
22905 //Script Info, information
22906 {
22907 disassembled_script_data* target = NULL;
22908 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
22909 {
22910 default:
22911 case 0: //FFC
22912 {
22913 int32_t id = assignscript_dlg[5].d1;
22914 if(id < 0 || asffcscripts[id] == "<none>" || asffcscripts[id].at(0) == '-') break;
22915 target = &(scripts[asffcscripts[id]]);
22916 break;
22917 }
22918 case 1: //Global
22919 {
22920 int32_t id = assignscript_dlg[8].d1;
22921 if(id < 0 || asglobalscripts[id] == "<none>" || asglobalscripts[id].at(0) == '-') break;
22922 target = &(scripts[asglobalscripts[id]]);
22923 break;
22924 }
22925 case 2: //Item
22926 {
22927 int32_t id = assignscript_dlg[11].d1;
22928 if(id < 0 || asitemscripts[id] == "<none>" || asitemscripts[id].at(0) == '-') break;
22929 target = &(scripts[asitemscripts[id]]);
22930 break;
22931 }
22932 case 3: //npc
22933 {
22934 int32_t id = assignscript_dlg[20].d1;
22935 if(id < 0 || asnpcscripts[id] == "<none>" || asnpcscripts[id].at(0) == '-') break;
22936 target = &(scripts[asnpcscripts[id]]);
22937 break;
22938 }
22939 case 4: //lweapon
22940 {
22941 int32_t id = assignscript_dlg[22].d1;
22942 if(id < 0 || aslweaponscripts[id] == "<none>" || aslweaponscripts[id].at(0) == '-') break;
22943 target = &(scripts[aslweaponscripts[id]]);
22944 break;
22945 }
22946 case 5: //eweapon
22947 {
22948 int32_t id = assignscript_dlg[25].d1;
22949 if(id < 0 || aseweaponscripts[id] == "<none>" || aseweaponscripts[id].at(0) == '-') break;
22950 target = &(scripts[aseweaponscripts[id]]);
22951 break;
22952 }
22953 case 6: //hero
22954 {
22955 int32_t id = assignscript_dlg[28].d1;
22956 if(id < 0 || asplayerscripts[id] == "<none>" || asplayerscripts[id].at(0) == '-') break;
22957 target = &(scripts[asplayerscripts[id]]);
22958 break;
22959 }
22960 case 7: //dmap
22961 {
22962 int32_t id = assignscript_dlg[34].d1;
22963 if(id < 0 || asdmapscripts[id] == "<none>" || asdmapscripts[id].at(0) == '-') break;
22964 target = &(scripts[asdmapscripts[id]]);
22965 break;
22966 }
22967 case 8: //screen
22968 {
22969 int32_t id = assignscript_dlg[31].d1;
22970 if(id < 0 || asscreenscripts[id] == "<none>" || asscreenscripts[id].at(0) == '-') break;
22971 target = &(scripts[asscreenscripts[id]]);
22972 break;
22973 }
22974 case 9: //itemsprite
22975 {
22976 int32_t id = assignscript_dlg[37].d1;
22977 if(id < 0 || asitemspritescripts[id] == "<none>" || asitemspritescripts[id].at(0) == '-') break;
22978 target = &(scripts[asitemspritescripts[id]]);
22979 break;
22980 }
22981 case 10: //combo
22982 {
22983 int32_t id = assignscript_dlg[40].d1;
22984 if(id < 0 || ascomboscripts[id] == "<none>" || ascomboscripts[id].at(0) == '-') break;
22985 target = &(scripts[ascomboscripts[id]]);
22986 break;
22987 }
22988 case 11: //generic
22989 {
22990 int32_t id = assignscript_dlg[46].d1;
22991 if(id < 0 || asgenericscripts[id] == "<none>" || asgenericscripts[id].at(0) == '-') break;
22992 target = &(scripts[asgenericscripts[id]]);
22993 break;
22994 }
22995 case 12: //subscreen
22996 {
22997 int32_t id = assignscript_dlg[49].d1;
22998 if(id < 0 || assubscreenscripts[id] == "<none>" || assubscreenscripts[id].at(0) == '-') break;
22999 target = &(scripts[assubscreenscripts[id]]);
23000 break;
23001 }
23002 }
23003 zasm_meta* meta = target ? &target->first : nullptr;
23004 if(devpwd() && CHECK_CTRL_CMD)
23005 {
23006 string str;
23007 target->write(str, false, false, (assignscript_dlg[51].flags == D_SELECTED), true);
23008 set_al_clipboard(str);
23009 displayinfo("Clipboard Copy","Copied ZASM of selected script to clipboard");
23010 }
23011 else if(meta)
23012 showScriptInfo(meta);
23013 break;
23014 }
23015
23016 case 44:
23017 //Clear, clear slots of current type- after a confirmation.
23018 {
23019 doClearSlots(&slotflags);
23020 break;
23021 }
23022 }
23023 }
23024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(assign_mode == 2) //Smart Assign
23025 {
23026 //For global/hero scripts, match slot names if unoccupied
23027 smart_slot_named(scripts, asglobalscripts, globalmap, global_slotnames, 1, NUMSCRIPTGLOBAL);
23028 smart_slot_named(scripts, asplayerscripts, playermap, player_slotnames, 0, NUMSCRIPTPLAYER-1);
23029 //For other scripts, assign all un-assigned scripts
23030 smart_slot_type(scripts, asffcscripts, ffcmap, NUMSCRIPTFFC-1);
23031 smart_slot_type(scripts, asitemscripts, itemmap, NUMSCRIPTITEM-1);
23032 smart_slot_type(scripts, asnpcscripts, npcmap, NUMSCRIPTGUYS-1);
23033 smart_slot_type(scripts, aslweaponscripts, lwpnmap, NUMSCRIPTWEAPONS-1);
23034 smart_slot_type(scripts, aseweaponscripts, ewpnmap, NUMSCRIPTWEAPONS-1);
23035 smart_slot_type(scripts, asscreenscripts, screenmap, NUMSCRIPTSCREEN-1);
23036 smart_slot_type(scripts, asdmapscripts, dmapmap, NUMSCRIPTSDMAP-1);
23037 smart_slot_type(scripts, asitemspritescripts, itemspritemap, NUMSCRIPTSITEMSPRITE-1);
23038 smart_slot_type(scripts, ascomboscripts, comboscriptmap, NUMSCRIPTSCOMBODATA-1);
23039 smart_slot_type(scripts, asgenericscripts, genericmap, NUMSCRIPTSGENERIC-1);
23040 smart_slot_type(scripts, assubscreenscripts, subscreenmap, NUMSCRIPTSSUBSCREEN-1);
23041 }
23042 auto_do_slots:
23043 4 doslots_log_output = (assignscript_dlg[13].flags == D_SELECTED);
23044 4 doslots_comment_output = (assignscript_dlg[51].flags == D_SELECTED);
23045 4 doslot_scripts = &scripts;
23046 //OK
23047 {
23048 4 auto start_assign_time = std::chrono::steady_clock::now();
23049
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(ffcmap, 1, ffscripts))
23050 goto exit_do_slots;
23051
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(globalmap, 0, globalscripts))
23052 goto exit_do_slots;
23053
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(itemmap, 1, itemscripts))
23054 goto exit_do_slots;
23055
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(npcmap, 1, guyscripts))
23056 goto exit_do_slots;
23057
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(lwpnmap, 1, lwpnscripts))
23058 goto exit_do_slots;
23059
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(ewpnmap, 1, ewpnscripts))
23060 goto exit_do_slots;
23061
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(playermap, 1, playerscripts))
23062 goto exit_do_slots;
23063
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(dmapmap, 1, dmapscripts))
23064 goto exit_do_slots;
23065
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(screenmap, 1, screenscripts))
23066 goto exit_do_slots;
23067
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(itemspritemap, 1, itemspritescripts))
23068 goto exit_do_slots;
23069
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(comboscriptmap, 1, comboscripts))
23070 goto exit_do_slots;
23071
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(genericmap, 1, genericscripts))
23072 goto exit_do_slots;
23073
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!handle_slot_map(subscreenmap, 1, subscreenscripts))
23074 goto exit_do_slots;
23075
23076 4 auto end_assign_time = std::chrono::steady_clock::now();
23077 4 int compile_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_assign_time - start_assign_time).count();
23078 4 al_trace("Assign Slots took %d ms\n", compile_time_ms);
23079 4 char buf[256] = {0};
23080 8 sprintf(buf, "ZScripts successfully loaded into script slots"
23081 4 "\nAssign Slots took %d ms", compile_time_ms);
23082 4 compile_finish_sample = vbound(zc_get_config("Compiler","compile_finish_sample",20),0,255);
23083 4 compile_audio_volume = vbound(zc_get_config("Compiler","compile_audio_volume",200),0,255);
23084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( compile_finish_sample > 0 )
23085 {
23086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sfxdat)
23087 sfx_voice[compile_finish_sample]=allocate_voice((SAMPLE*)sfxdata[compile_finish_sample].dat);
23088 4 else sfx_voice[compile_finish_sample]=allocate_voice(&customsfxdata[compile_finish_sample]);
23089 4 voice_set_volume(sfx_voice[compile_finish_sample], compile_audio_volume);
23090 4 voice_start(sfx_voice[compile_finish_sample]);
23091 4 }
23092
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!assign_mode)
23093 InfoDialog("Slots Assigned",buf).show();
23094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( compile_finish_sample > 0 )
23095 {
23096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sfx_voice[compile_finish_sample]!=-1)
23097 {
23098 4 deallocate_voice(sfx_voice[compile_finish_sample]);
23099 4 sfx_voice[compile_finish_sample]=-1;
23100 4 }
23101 4 }
23102 4 build_biffs_list();
23103 4 build_biitems_list();
23104 4 retval = true;
23105 4 goto exit_do_slots;
23106 }
23107 exit_do_slots:
23108 4 doslot_scripts = nullptr;
23109 4 popup_zqdialog_end();
23110 4 return retval;
23111 }
23112
23113 static char slottype_str_buf[32];
23114
23115 const char *slottype_list(int32_t index, int32_t *list_size)
23116 {
23117 if(index >= 0)
23118 {
23119 bound(index,0,num_types-1);
23120
23121 switch(index)
23122 {
23123 case type_ffc:
23124 strcpy(slottype_str_buf, "FFC");
23125 break;
23126 case type_global:
23127 strcpy(slottype_str_buf, "Global");
23128 break;
23129 case type_itemdata:
23130 strcpy(slottype_str_buf, "Item");
23131 break;
23132 case type_npc:
23133 strcpy(slottype_str_buf, "NPC");
23134 break;
23135 case type_lweapon:
23136 strcpy(slottype_str_buf, "LWeapon");
23137 break;
23138 case type_eweapon:
23139 strcpy(slottype_str_buf, "EWeapon");
23140 break;
23141 case type_hero:
23142 strcpy(slottype_str_buf, "Hero");
23143 break;
23144 case type_dmap:
23145 strcpy(slottype_str_buf, "DMap");
23146 break;
23147 case type_screen:
23148 strcpy(slottype_str_buf, "Screen");
23149 break;
23150 case type_itemsprite:
23151 strcpy(slottype_str_buf, "ItemSprite");
23152 break;
23153 case type_combo:
23154 strcpy(slottype_str_buf, "Combo");
23155 break;
23156 case type_generic:
23157 strcpy(slottype_str_buf, "Generic");
23158 break;
23159 case type_subscreen:
23160 strcpy(slottype_str_buf, "Subscreen");
23161 break;
23162 }
23163
23164 return slottype_str_buf;
23165 }
23166 *list_size = 11;
23167 return NULL;
23168 }
23169 9 static ListData slottype_sel_list(slottype_list, &font);
23170
23171 static DIALOG clearslots_dlg[] =
23172 {
23173 9 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear Slots", NULL, NULL },
23174 9 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23175 9 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23176 9 { jwin_droplist_proc, 50, 28+16, 70, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23177 9 { jwin_radio_proc, 40, 34+00, 81, 9, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Clear Script Type:", NULL, NULL },
23178 9 { jwin_radio_proc, 40, 34+32, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Missing (--) Slots", NULL, NULL },
23179 9 { jwin_radio_proc, 40, 34+48, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Preserved (++) Slots", NULL, NULL },
23180 9 { jwin_radio_proc, 40, 34+64, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Imported (==) Slots", NULL, NULL },
23181 9 { jwin_radio_proc, 40, 34+80, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear All", NULL, NULL },
23182 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23183 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23184 };
23185
23186 void doClearSlots(byte* flags)
23187 {
23188 //{ Setup
23189 clearslots_dlg[0].dp2=get_zc_font(font_lfont);
23190 clearslots_dlg[3].d1 = get_selected_tab((TABPANEL*)assignscript_dlg[1].dp); //Default to current tab's type
23191 clearslots_dlg[4].flags |= D_SELECTED;
23192 clearslots_dlg[5].flags &= ~D_SELECTED;
23193 clearslots_dlg[6].flags &= ~D_SELECTED;
23194 clearslots_dlg[7].flags &= ~D_SELECTED;
23195 clearslots_dlg[8].flags &= ~D_SELECTED;
23196 if(((*flags) & SLOTMSGFLAG_MISSING) == 0)
23197 clearslots_dlg[5].flags |= D_DISABLED;
23198 else
23199 clearslots_dlg[5].flags &= ~D_DISABLED;
23200 if(((*flags) & SLOTMSGFLAG_PRESERVED) == 0)
23201 clearslots_dlg[6].flags |= D_DISABLED;
23202 else
23203 clearslots_dlg[6].flags &= ~D_DISABLED;
23204 if(((*flags) & SLOTMSGFLAG_IMPORTED) == 0)
23205 clearslots_dlg[7].flags |= D_DISABLED;
23206 else
23207 clearslots_dlg[7].flags &= ~D_DISABLED;
23208 //}
23209
23210 large_dialog(clearslots_dlg);
23211
23212 if(do_zqdialog(clearslots_dlg,2)==1)
23213 {
23214 int32_t q = 3;
23215 while((clearslots_dlg[++q].flags & D_SELECTED) == 0);
23216 switch(q)
23217 {
23218 case 4: //Clear type
23219 {
23220 clearAllSlots(clearslots_dlg[3].d1);
23221 break;
23222 }
23223 case 5: //Clear Missing
23224 {
23225 for(int32_t q = 0; q <= 10; ++q)
23226 clearAllSlots(q,SLOTMSGFLAG_MISSING);
23227 break;
23228 }
23229 case 6: //Clear Preserved
23230 {
23231 for(int32_t q = 0; q <= 10; ++q)
23232 clearAllSlots(q,SLOTMSGFLAG_PRESERVED);
23233 break;
23234 }
23235 case 7: //Clear Imported ZASM
23236 {
23237 for(int32_t q = 0; q <= 10; ++q)
23238 clearAllSlots(q,SLOTMSGFLAG_IMPORTED);
23239 break;
23240 }
23241 case 8: //Clear ALL
23242 {
23243 for(int32_t q = 0; q <= 10; ++q)
23244 clearAllSlots(q);
23245 break;
23246 }
23247 }
23248 }
23249 }
23250
23251 static DIALOG exportzasm_dlg[] =
23252 {
23253 9 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Export ZASM", NULL, NULL },
23254 9 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23255 9 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23256 9 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23257 9 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
23258 9 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
23259 9 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
23260 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23261 };
23262
23263 static DIALOG importzasm_dlg[] =
23264 {
23265 9 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import ZASM", NULL, NULL },
23266 9 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
23267 9 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23268 9 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
23269 9 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
23270 // 5
23271 9 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
23272 9 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
23273 9 { jwin_text_proc, 50, 28+72, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Name:", NULL, NULL },
23274 9 { jwin_edit_proc, 50, 28+80, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 19, 0, NULL, NULL, NULL },
23275
23276 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23277 };
23278 extern ListData itemscript_list;
23279 extern ListData itemspritescript_list;
23280 extern ListData lweaponscript_list;
23281 extern ListData npcscript_list;
23282 extern ListData eweaponscript_list;
23283 extern ListData comboscript_list;
23284
23285 static EXT_LIST zasm_extlist[] =
23286 {
23287 { (char *)"ZASM Files (*.zasm)", (char *)"zasm" },
23288 { NULL, NULL }
23289 };
23290
23291 int32_t onImportZASM()
23292 {
23293 importzasm_dlg[0].dp2 = get_zc_font(font_lfont);
23294 importzasm_dlg[4].dp = (void*)&ffscript_list;
23295 if(!prompt_for_existing_file_compat("Import Script (.zasm)","zasm",zasm_extlist,datapath,false))
23296 {
23297 return D_O_K;
23298 }
23299 script_data *temp_slot = new script_data(ScriptType::None, 0);
23300 if(parse_script_file(temp_slot, temppath, false) == D_CLOSE)
23301 {
23302 jwin_alert("Error","Failed to parse specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
23303 delete temp_slot;
23304 return D_O_K;
23305 }
23306
23307 std::string namebuf;
23308 if(temp_slot->meta.valid()) //Found metadata
23309 {
23310 importzasm_dlg[3].d1 = getType(temp_slot->meta.script_type);
23311 namebuf = temp_slot->meta.script_name;
23312 switch(importzasm_dlg[3].d1)
23313 {
23314 default: //Shouldn't occur, but to be safe
23315 case type_ffc:
23316 importzasm_dlg[4].dp = (void*)&ffscript_sel_dlg_list;
23317 break;
23318 case type_global:
23319 importzasm_dlg[4].dp = (void*)&gscript_sel_dlg_list;
23320 break;
23321 case type_itemdata:
23322 importzasm_dlg[4].dp = (void*)&itemscript_sel_dlg_list;
23323 break;
23324 case type_npc:
23325 importzasm_dlg[4].dp = (void*)&npcscript_sel_dlg_list;
23326 break;
23327 case type_lweapon:
23328 importzasm_dlg[4].dp = (void*)&lweaponscript_sel_dlg_list;
23329 break;
23330 case type_eweapon:
23331 importzasm_dlg[4].dp = (void*)&eweaponscript_sel_dlg_list;
23332 break;
23333 case type_hero:
23334 importzasm_dlg[4].dp = (void*)&playerscript_sel_dlg_list;
23335 break;
23336 case type_dmap:
23337 importzasm_dlg[4].dp = (void*)&dmapscript_sel_dlg_list;
23338 break;
23339 case type_screen:
23340 importzasm_dlg[4].dp = (void*)&screenscript_sel_dlg_list;
23341 break;
23342 case type_itemsprite:
23343 importzasm_dlg[4].dp = (void*)&itemspritescript_sel_dlg_list;
23344 break;
23345 case type_combo:
23346 importzasm_dlg[4].dp = (void*)&comboscript_sel_dlg_list;
23347 break;
23348 }
23349 importzasm_dlg[4].d1 = 0;
23350 }
23351 else
23352 {
23353 importzasm_dlg[3].d1 = 0;
23354 importzasm_dlg[4].dp = (void*)&ffscript_list;
23355 importzasm_dlg[4].d1 = 0;
23356 }
23357 importzasm_dlg[8].dp = (void*)namebuf.c_str();
23358 bool confirmed = false;
23359 int32_t indx = 1;
23360 while(!confirmed)
23361 {
23362 large_dialog(importzasm_dlg);
23363 indx = do_zqdialog(importzasm_dlg, indx);
23364 switch(indx)
23365 {
23366 case 1: //confirm; exit dlg
23367 {
23368 if(!namebuf[0]) break; //No name?
23369 script_data **slot = NULL;
23370 script_slot_data *map = NULL;
23371 //{ Find script choice
23372 int32_t scriptInd = importzasm_dlg[4].d1;
23373 switch(importzasm_dlg[3].d1)
23374 {
23375 case type_ffc:
23376 slot = &ffscripts[scriptInd];
23377 map = &ffcmap[scriptInd];
23378 break;
23379 case type_global:
23380 slot = &globalscripts[scriptInd];
23381 map = &globalmap[scriptInd];
23382 break;
23383 case type_itemdata:
23384 slot = &itemscripts[scriptInd];
23385 map = &itemmap[scriptInd];
23386 break;
23387 case type_npc:
23388 slot = &guyscripts[scriptInd];
23389 map = &npcmap[scriptInd];
23390 break;
23391 case type_lweapon:
23392 slot = &lwpnscripts[scriptInd];
23393 map = &lwpnmap[scriptInd];
23394 break;
23395 case type_eweapon:
23396 slot = &ewpnscripts[scriptInd];
23397 map = &ewpnmap[scriptInd];
23398 break;
23399 case type_hero:
23400 slot = &playerscripts[scriptInd];
23401 map = &playermap[scriptInd];
23402 break;
23403 case type_dmap:
23404 slot = &dmapscripts[scriptInd];
23405 map = &dmapmap[scriptInd];
23406 break;
23407 case type_screen:
23408 slot = &screenscripts[scriptInd];
23409 map = &screenmap[scriptInd];
23410 break;
23411 case type_itemsprite:
23412 slot = &itemspritescripts[scriptInd];
23413 map = &itemspritemap[scriptInd];
23414 break;
23415 case type_combo:
23416 slot = &comboscripts[scriptInd];
23417 map = &comboscriptmap[scriptInd];
23418 break;
23419 case type_generic:
23420 slot = &genericscripts[scriptInd];
23421 map = &genericmap[scriptInd];
23422 break;
23423 case type_subscreen:
23424 slot = &subscreenscripts[scriptInd];
23425 map = &subscreenmap[scriptInd];
23426 break;
23427 }
23428 //}
23429 if(!slot) break; //Not found?
23430 *slot = std::move(temp_slot);
23431 map->format = SCRIPT_FORMAT_ZASM;
23432 map->updateName(namebuf);
23433 confirmed = true;
23434 break;
23435 }
23436 case 0: case 2: //Close dlg
23437 {
23438 delete temp_slot;
23439 return D_O_K;
23440 }
23441 case 3: //Type select
23442 {
23443 switch(importzasm_dlg[3].d1)
23444 {
23445 default: //Shouldn't occur, but to be safe
23446 case type_ffc:
23447 importzasm_dlg[4].dp = (void*)&ffscript_sel_dlg_list;
23448 break;
23449 case type_global:
23450 importzasm_dlg[4].dp = (void*)&gscript_sel_dlg_list;
23451 break;
23452 case type_itemdata:
23453 importzasm_dlg[4].dp = (void*)&itemscript_sel_dlg_list;
23454 break;
23455 case type_npc:
23456 importzasm_dlg[4].dp = (void*)&npcscript_sel_dlg_list;
23457 break;
23458 case type_lweapon:
23459 importzasm_dlg[4].dp = (void*)&lweaponscript_sel_dlg_list;
23460 break;
23461 case type_eweapon:
23462 importzasm_dlg[4].dp = (void*)&eweaponscript_sel_dlg_list;
23463 break;
23464 case type_hero:
23465 importzasm_dlg[4].dp = (void*)&playerscript_sel_dlg_list;
23466 break;
23467 case type_dmap:
23468 importzasm_dlg[4].dp = (void*)&dmapscript_sel_dlg_list;
23469 break;
23470 case type_screen:
23471 importzasm_dlg[4].dp = (void*)&screenscript_sel_dlg_list;
23472 break;
23473 case type_itemsprite:
23474 importzasm_dlg[4].dp = (void*)&itemspritescript_sel_dlg_list;
23475 break;
23476 case type_combo:
23477 importzasm_dlg[4].dp = (void*)&comboscript_sel_dlg_list;
23478 break;
23479 }
23480 importzasm_dlg[4].d1 = 0;
23481 break;
23482 }
23483 }
23484 }
23485 delete temp_slot;
23486 return D_O_K;
23487 }
23488
23489 6 void center_zscript_dialogs()
23490 {
23491 6 jwin_center_dialog(exportzasm_dlg);
23492 6 jwin_center_dialog(importzasm_dlg);
23493 6 jwin_center_dialog(clearslots_dlg);
23494 6 }
23495
23496 static DIALOG sfxlist_dlg[] =
23497 {
23498 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
23499 9 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
23500 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23501 9 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
23502 9 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
23503 9 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
23504 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23505 };
23506
23507 int32_t select_sfx(const char *prompt,int32_t index)
23508 {
23509 sfxlist_dlg[0].dp=(void *)prompt;
23510 sfxlist_dlg[0].dp2=get_zc_font(font_lfont);
23511 sfxlist_dlg[2].d1=index;
23512 sfxlist_dlg[2].dp=(void *) & sfx_list;
23513
23514 large_dialog(sfxlist_dlg);
23515
23516 int32_t ret=do_zqdialog(sfxlist_dlg,2);
23517
23518 if(ret==0||ret==4)
23519 {
23520 position_mouse_z(0);
23521 return -1;
23522 }
23523
23524 index = sfxlist_dlg[2].d1;
23525 position_mouse_z(0);
23526 return index;
23527 }
23528
23529 static DIALOG sfx_edit_dlg[] =
23530 {
23531 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "SFX", NULL, NULL },
23532 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
23533 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
23534 { jwin_button_proc, 35, 78, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
23535 { jwin_button_proc, 35, 105, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Play", NULL, NULL },
23536 { jwin_button_proc, 104, 105, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Stop", NULL, NULL },
23537 { jwin_button_proc, 104, 78, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Default", NULL, NULL },
23538 { jwin_edit_proc, 36, 25, 154, 16, vc(12), vc(1), 0, 0, 36, 0, NULL, NULL, NULL },
23539 { jwin_text_proc, 8, 30, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
23540 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
23541 { jwin_button_proc, 70, 51, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
23542 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
23543 };
23544
23545
23546 // array of voices, one for each sfx sample in the data file
23547 // 0+ = voice #
23548 // -1 = voice not allocated
23549 int32_t sfx_voice[WAV_COUNT];
23550
23551 void Z_init_sound()
23552 {
23553 for(int32_t i=0; i<WAV_COUNT; i++)
23554 sfx_voice[i]=-1;
23555
23556 // master_volume(digi_volume,midi_volume);
23557 }
23558
23559 // returns number of voices currently allocated
23560 int32_t sfx_count()
23561 {
23562 int32_t c=0;
23563
23564 for(int32_t i=0; i<WAV_COUNT; i++)
23565 if(sfx_voice[i]!=-1)
23566 ++c;
23567
23568 return c;
23569 }
23570
23571 // clean up finished samples
23572 void sfx_cleanup()
23573 {
23574 for(int32_t i=0; i<WAV_COUNT; i++)
23575 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
23576 {
23577 deallocate_voice(sfx_voice[i]);
23578 sfx_voice[i]=-1;
23579 }
23580 }
23581
23582 // allocates a voice for the sample "wav_index" (index into zelda.dat)
23583 // if a voice is already allocated (and/or playing), then it just returns true
23584 // Returns true: voice is allocated
23585 // false: unsuccessful
23586 SAMPLE templist[WAV_COUNT];
23587
23588 bool sfx_init(int32_t index)
23589 {
23590 // check index
23591 if(index<1 || index>=WAV_COUNT)
23592 return false;
23593
23594 if(sfx_voice[index]==-1)
23595 {
23596 sfx_voice[index]=allocate_voice(&templist[index]);
23597 }
23598
23599 return sfx_voice[index] != -1;
23600 }
23601
23602 // plays an sfx sample
23603 void sfx(int32_t index,int32_t pan,bool loop,bool restart,int32_t vol,int32_t freq)
23604 {
23605 if(!sfx_init(index))
23606 return;
23607
23608 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
23609 voice_set_pan(sfx_voice[index],pan);
23610
23611 int32_t pos = voice_get_position(sfx_voice[index]);
23612
23613 if(restart) voice_set_position(sfx_voice[index],0);
23614
23615 if(pos<=0)
23616 voice_start(sfx_voice[index]);
23617 }
23618
23619 // start it (in loop mode) if it's not already playing,
23620 // otherwise just leave it in its current position
23621 void cont_sfx(int32_t index)
23622 {
23623 if(!sfx_init(index))
23624 return;
23625
23626 if(voice_get_position(sfx_voice[index])<=0)
23627 {
23628 voice_set_position(sfx_voice[index],0);
23629 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
23630 voice_start(sfx_voice[index]);
23631 }
23632 }
23633
23634 // adjust parameters while playing
23635 void adjust_sfx(int32_t index,int32_t pan,bool loop)
23636 {
23637 if(index<0 || index>=WAV_COUNT || sfx_voice[index]==-1)
23638 return;
23639
23640 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
23641 voice_set_pan(sfx_voice[index],pan);
23642 }
23643
23644 // pauses a voice
23645 void pause_sfx(int32_t index)
23646 {
23647 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
23648 voice_stop(sfx_voice[index]);
23649 }
23650
23651 // resumes a voice
23652 void resume_sfx(int32_t index)
23653 {
23654 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
23655 voice_start(sfx_voice[index]);
23656 }
23657
23658 // pauses all active voices
23659 void pause_all_sfx()
23660 {
23661 for(int32_t i=0; i<WAV_COUNT; i++)
23662 if(sfx_voice[i]!=-1)
23663 voice_stop(sfx_voice[i]);
23664 }
23665
23666 // resumes all paused voices
23667 void resume_all_sfx()
23668 {
23669 for(int32_t i=0; i<WAV_COUNT; i++)
23670 if(sfx_voice[i]!=-1)
23671 voice_start(sfx_voice[i]);
23672 }
23673
23674 // stops an sfx and deallocates the voice
23675 void stop_sfx(int32_t index)
23676 {
23677 if(index<0 || index>=WAV_COUNT)
23678 return;
23679
23680 if(sfx_voice[index]!=-1)
23681 {
23682 deallocate_voice(sfx_voice[index]);
23683 sfx_voice[index]=-1;
23684 }
23685 }
23686
23687 void kill_sfx()
23688 {
23689 for(int32_t i=0; i<WAV_COUNT; i++)
23690 if(sfx_voice[i]!=-1)
23691 {
23692 deallocate_voice(sfx_voice[i]);
23693 sfx_voice[i]=-1;
23694 }
23695 }
23696
23697 int32_t pan(int32_t x)
23698 {
23699 return 128;
23700 /*switch(pan_style)
23701 {
23702 case 0: return 128;
23703 case 1: return vbound((x>>1)+68,0,255);
23704 case 2: return vbound(((x*3)>>2)+36,0,255);
23705 }
23706 return vbound(x,0,255);*/
23707 }
23708
23709
23710 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2)
23711 {
23712 sfx1->bits = sfx2->bits;
23713 sfx1->stereo = sfx2->stereo;
23714 sfx1->freq = sfx2->freq;
23715 sfx1->priority = sfx2->priority;
23716 sfx1->len = sfx2->len;
23717 sfx1->loop_start = sfx2->loop_start;
23718 sfx1->loop_end = sfx2->loop_end;
23719 sfx1->param = sfx2->param;
23720
23721 if(sfx1->data != NULL)
23722 {
23723 free(sfx1->data);
23724 }
23725
23726 if(sfx2->data == NULL)
23727 sfx1->data = NULL;
23728 else
23729 {
23730 // When quests are saved and loaded, data is written in words.
23731 // If the last byte is dropped, it'll cause the sound to end with
23732 // a click. It could simply be extended and padded with 0, but
23733 // that causes compatibility issues... So we'll cut off
23734 // the last byte and decrease the length.
23735
23736 int32_t len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
23737
23738 while(len%sizeof(word))
23739 {
23740 // sizeof(word) should be 2, so this doesn't really need
23741 // to be a loop, but what the heck.
23742 sfx1->len--;
23743 len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
23744 }
23745
23746 sfx1->data = malloc(len);
23747 memcpy(sfx1->data, sfx2->data, len);
23748 }
23749 }
23750
23751 bool confirmBox(const char *m1, const char *m2, const char *m3)
23752 {
23753 if(!m3)
23754 {
23755 if(!m2) m2 = "Are you sure?";
23756 else m3 = "Are you sure?";
23757 }
23758 return jwin_alert("Confirmation", m1, m2, m3, "Yes", "No", 'y', 'n', get_zc_font(font_lfont)) == 1;
23759 }
23760
23761 int32_t onSelectSFX()
23762 {
23763 int32_t index = select_sfx("Select SFX",0);
23764
23765 while(index >= 0)
23766 {
23767 if(index)
23768 onEditSFX(index);
23769
23770 index = select_sfx("Select SFX",index);
23771 }
23772
23773 refresh(rMAP+rCOMBOS);
23774 return D_O_K;
23775 }
23776
23777 bool saveWAV(int32_t slot, const char *filename)
23778 {
23779 if (slot < 1 || slot >= 511 )
23780 return false;
23781
23782 if (customsfxdata[slot].data == NULL)
23783 return false;
23784
23785 std::ofstream ofs(filename, std::ios::binary);
23786 if (!ofs)
23787 return false;
23788 ofs.write("RIFF",4);
23789 uint32_t samplerate = customsfxdata[slot].freq;
23790 uint16_t channels = customsfxdata[slot].stereo ? 2 : 1;
23791 uint32_t datalen = customsfxdata[slot].len*channels*customsfxdata[slot].bits / 8;
23792 uint32_t size = 36 + datalen;
23793 ofs.write((char *)&size, 4);
23794 ofs.write("WAVE", 4);
23795 ofs.write("fmt ", 4);
23796 uint32_t fmtlen = 16;
23797 ofs.write((char *)&fmtlen, 4);
23798 uint16_t type = 1;
23799 ofs.write((char *)&type, 2);
23800 ofs.write((char *)&channels, 2);
23801 ofs.write((char *)&samplerate, 4);
23802 uint32_t bytespersec = samplerate*channels*customsfxdata[slot].bits / 8;
23803 ofs.write((char *)&bytespersec, 4);
23804 uint16_t blockalign = channels*customsfxdata[slot].bits / 8;
23805 ofs.write((char *)&blockalign, 2);
23806 uint16_t bitspersample = customsfxdata[slot].bits;
23807 ofs.write((char *)&bitspersample, 2);
23808 ofs.write("data", 4);
23809 ofs.write((char *)&datalen, 4);
23810 if (bitspersample == 8)
23811 {
23812 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
23813 {
23814 char data = ((char *)customsfxdata[slot].data)[i];
23815 data ^= 0x80;
23816 ofs.write(&data, 1);
23817 }
23818 }
23819 else if (bitspersample == 16)
23820 {
23821 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
23822 {
23823 uint16_t data = ((uint16_t *)customsfxdata[slot].data)[i];
23824 data ^= 0x8000;
23825 ofs.write((char *)&data, 2);
23826 }
23827 }
23828 else
23829 return false;
23830 return !!ofs;
23831 }
23832
23833 int32_t onEditSFX(int32_t index)
23834 {
23835 kill_sfx();
23836 zc_stop_midi();
23837 zc_set_volume(255,-1);
23838 int32_t ret;
23839 sfx_edit_dlg[0].dp2=get_zc_font(font_lfont);
23840 uint8_t tempflag;
23841 tempflag = get_bit(customsfxflag,index-1);
23842 change_sfx(&templist[index], &customsfxdata[index]);
23843
23844 char sfxnumstr[50];
23845 sprintf(sfxnumstr,"SFX %d: %s", index, sfx_string[index]);
23846 sfx_edit_dlg[0].dp = sfxnumstr;
23847
23848 char name[36];
23849 strcpy(name,sfx_string[index]);
23850 sfx_edit_dlg[7].dp = name;
23851
23852 large_dialog(sfx_edit_dlg);
23853
23854 do
23855 {
23856 ret=do_zqdialog(sfx_edit_dlg,1);
23857
23858 switch(ret)
23859 {
23860 case 1:
23861 saved= false;
23862 kill_sfx();
23863 change_sfx(&customsfxdata[index],&templist[index]);
23864 set_bit(customsfxflag,index-1,tempflag);
23865 strcpy(sfx_string[index], name);
23866
23867 case 2:
23868 case 0:
23869 // Fall Through
23870 kill_sfx();
23871
23872 for(int32_t i=1; i<WAV_COUNT; i++)
23873 {
23874 if(templist[i].data != NULL)
23875 {
23876 free(templist[i].data);
23877 templist[i].data = NULL;
23878 }
23879 }
23880
23881 break;
23882
23883 case 3:
23884 if(prompt_for_existing_file_compat("Open .WAV file", "wav", NULL,temppath, true))
23885 {
23886 SAMPLE * temp_sample;
23887
23888 if((temp_sample = load_wav(temppath))==NULL)
23889 {
23890 jwin_alert("Error","Could not open file",temppath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
23891 }
23892 else
23893 {
23894 char sfxtitle[36];
23895 char *t = get_filename(temppath);
23896 int32_t j;
23897
23898 for(j=0; j<35 && t[j]!=0 && t[j]!='.'; j++)
23899 {
23900 sfxtitle[j]=t[j];
23901 }
23902
23903 sfxtitle[j]=0;
23904 strcpy(name,sfxtitle);
23905 kill_sfx();
23906 change_sfx(&templist[index], temp_sample);
23907 destroy_sample(temp_sample);
23908 tempflag = 1;
23909 }
23910 }
23911
23912 break;
23913
23914 case 4:
23915 {
23916 kill_sfx();
23917
23918 if(templist[index].data != NULL)
23919 {
23920 sfx(index, 128, false,true);
23921 }
23922 }
23923 break;
23924
23925 case 5:
23926 kill_sfx();
23927 break;
23928
23929 case 6:
23930 kill_sfx();
23931
23932 if(index < WAV_COUNT)
23933 {
23934 SAMPLE *temp_sample = (SAMPLE *)sfxdata[zc_min(index,Z35)].dat;
23935 change_sfx(&templist[index], temp_sample);
23936 tempflag = 1; //now count as custom sfx
23937 sprintf(name,"s%03d", index);
23938
23939 if(index <Z35)
23940 {
23941 strcpy(name, old_sfx_string[index-1]);
23942 }
23943 }
23944
23945 break;
23946
23947
23948 case 10:
23949 {
23950 temppath[0]=0;//memset(temppath, 0, sizeof(temppath));
23951 char tempname[36];
23952 strcpy(tempname,sfx_string[index]);
23953 //change spaces to dashes for f/s safety
23954 for ( int32_t q = 0; q < 36; ++q )
23955 {
23956 if(tempname[q] == 32 || tempname[q] == 47 || tempname[q] == 92 ) //SPACE, Bslash, Fslash
23957 tempname[q] = 45; //becomes hyphen
23958 }
23959
23960 tempname[35] = 0;
23961
23962 strcpy(temppath,tempname);
23963
23964 //save
23965 if(templist[index].data != NULL)
23966 {
23967 if (prompt_for_new_file_compat("Save .WAV file", "wav", NULL, temppath, true))
23968 {
23969 if(!saveWAV(index, temppath))
23970 {
23971 jwin_alert("Error!", "Could not write file", temppath, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
23972 }
23973 else
23974 {
23975 jwin_alert("Success!", "Saved WAV file", temppath, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
23976 }
23977 }
23978 }
23979 else
23980 {
23981 jwin_alert("Error!", "Cannot save an enpty slot!", NULL, NULL, "OK", NULL, 13, 27, get_zc_font(font_lfont));
23982 }
23983 break;
23984 }
23985 }
23986 }
23987 while(ret>2);
23988
23989 return D_O_K;
23990 }
23991
23992
23993 static DIALOG mapstyles_dlg[] =
23994 {
23995 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
23996 { jwin_win_proc, 0, 0, 307, 186, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Map Styles", NULL, NULL },
23997 { jwin_ctext_proc, 24, 34, 36, 36, 0, 0, 0, 0, 0, 0, (void *) "Frame", NULL, NULL }, //frame
23998 { jwin_ctext_proc, 68, 26, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Triforce", NULL, NULL }, //triforce fragment
23999 { jwin_ctext_proc, 68, 34, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Fragment", NULL, NULL }, //triforce fragment
24000 { jwin_ctext_proc, 152, 26, 100, 52, 0, 0, 0, 0, 0, 0, (void *) "Triforce Frame", NULL, NULL }, //triforce frame
24001 { jwin_ctext_proc, 152, 34, 100, 52, 0, 0, 0, 0, 0, 0, (void *) "(Normal or Double Sized)", NULL, NULL }, //triforce frame
24002 { jwin_ctext_proc, 260, 34, 84, 52, 0, 0, 0, 0, 0, 0, (void *) "Overworld Map", NULL, NULL }, //overworld map
24003 { jwin_ctext_proc, 24, 82, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Heart", NULL, NULL }, //heart container piece
24004 { jwin_ctext_proc, 24, 90, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Container", NULL, NULL }, //heart container piece
24005 { jwin_ctext_proc, 24, 98, 20, 20, 0, 0, 0, 0, 0, 0, (void *) "Piece", NULL, NULL }, //heart container piece
24006 { jwin_ctext_proc, 260, 98, 84, 52, 0, 0, 0, 0, 0, 0, (void *) "Dungeon Map", NULL, NULL }, //dungeon map
24007 // 11
24008 { jwin_frame_proc, 6, 42, 36, 36, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //frame
24009 // { jwin_frame_proc, 50, 42, 36, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //bs triforce fragment
24010 { jwin_frame_proc, 58, 42, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //normal triforce fragment
24011 // { jwin_frame_proc, 94, 42, 116, 116, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //bs triforce frame
24012 { jwin_frame_proc, 102, 42, 100, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //normaltriforce frame
24013 { jwin_frame_proc, 218, 42, 84, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //overworld map
24014 { jwin_frame_proc, 14, 106, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //heart container piece
24015 { jwin_frame_proc, 218, 106, 84, 52, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL }, //dungeon map
24016 // 17
24017 { d_maptile_proc, 8, 44, 32, 32, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //frame
24018 // { d_maptile_proc, 52, 44, 32, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, //bs triforce fragment
24019 { d_maptile_proc, 60, 44, 16, 16, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //normal triforce fragment
24020 // { d_maptile_proc, 96, 44, 112, 112, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, //bs triforce frame
24021 { d_maptile_proc, 104, 44, 96, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //normal triforce frame
24022 { d_maptile_proc, 220, 44, 80, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //overworld map
24023 { d_maptile_proc, 16, 108, 16, 16, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //heart container piece
24024 { d_maptile_proc, 220, 108, 80, 48, 0, 0, 0, 0, 0, 0, NULL, (void*)1, NULL }, //dungeon map
24025 // 23
24026 { jwin_button_proc, 83, 162, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24027 { jwin_button_proc, 163, 162, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24028 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24029 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24030 };
24031
24032 int32_t onMapStyles()
24033 {
24034 if(mapstyles_dlg[0].d1<1)
24035 {
24036 mapstyles_dlg[12].x=mapstyles_dlg[0].x+50;
24037 mapstyles_dlg[12].w=36;
24038 mapstyles_dlg[12].h=52;
24039 mapstyles_dlg[13].x=mapstyles_dlg[0].x+94;
24040 mapstyles_dlg[13].w=116;
24041 mapstyles_dlg[13].h=116;
24042 mapstyles_dlg[18].x=mapstyles_dlg[12].x+2;
24043 mapstyles_dlg[18].w=mapstyles_dlg[12].w-4;
24044 mapstyles_dlg[18].h=mapstyles_dlg[12].h-4;
24045 mapstyles_dlg[19].x=mapstyles_dlg[13].x+2;
24046 mapstyles_dlg[19].w=mapstyles_dlg[13].w-4;
24047 mapstyles_dlg[19].h=mapstyles_dlg[13].h-4;
24048 }
24049
24050 mapstyles_dlg[0].dp2 = get_zc_font(font_lfont);
24051 mapstyles_dlg[17].d1 = QMisc.colors.blueframe_tile;
24052 mapstyles_dlg[17].fg = QMisc.colors.blueframe_cset;
24053 mapstyles_dlg[18].d1 = QMisc.colors.triforce_tile;
24054 mapstyles_dlg[18].fg = QMisc.colors.triforce_cset;
24055 mapstyles_dlg[19].d1 = QMisc.colors.triframe_tile;
24056 mapstyles_dlg[19].fg = QMisc.colors.triframe_cset;
24057 mapstyles_dlg[20].d1 = QMisc.colors.overworld_map_tile;
24058 mapstyles_dlg[20].fg = QMisc.colors.overworld_map_cset;
24059 mapstyles_dlg[21].d1 = QMisc.colors.HCpieces_tile;
24060 mapstyles_dlg[21].fg = QMisc.colors.HCpieces_cset;
24061 mapstyles_dlg[22].d1 = QMisc.colors.dungeon_map_tile;
24062 mapstyles_dlg[22].fg = QMisc.colors.dungeon_map_cset;
24063
24064 large_dialog(mapstyles_dlg,2);
24065
24066 go();
24067 int32_t ret = do_zqdialog(mapstyles_dlg,-1);
24068 comeback();
24069
24070 if(ret==23)
24071 {
24072 QMisc.colors.blueframe_tile = mapstyles_dlg[17].d1;
24073 QMisc.colors.blueframe_cset = mapstyles_dlg[17].fg;
24074 QMisc.colors.triforce_tile = mapstyles_dlg[18].d1;
24075 QMisc.colors.triforce_cset = mapstyles_dlg[18].fg;
24076 QMisc.colors.triframe_tile = mapstyles_dlg[19].d1;
24077 QMisc.colors.triframe_cset = mapstyles_dlg[19].fg;
24078 QMisc.colors.overworld_map_tile = mapstyles_dlg[20].d1;
24079 QMisc.colors.overworld_map_cset = mapstyles_dlg[20].fg;
24080 QMisc.colors.HCpieces_tile = mapstyles_dlg[21].d1;
24081 QMisc.colors.HCpieces_cset = mapstyles_dlg[21].fg;
24082 QMisc.colors.dungeon_map_tile = mapstyles_dlg[22].d1;
24083 QMisc.colors.dungeon_map_cset = mapstyles_dlg[22].fg;
24084 saved=false;
24085 }
24086
24087 return D_O_K;
24088 }
24089
24090 int32_t d_misccolors_old_proc(int32_t msg,DIALOG *d,int32_t c)
24091 {
24092 //these are here to bypass compiler warnings about unused arguments
24093 c=c;
24094
24095 if(msg==MSG_DRAW)
24096 {
24097 textout_ex(screen,font,"0123456789ABCDEF",d->x+8,d->y,d->fg,d->bg);
24098 textout_ex(screen,font,"0",d->x,d->y+8,d->fg,d->bg);
24099 textout_ex(screen,font,"1",d->x,d->y+16,d->fg,d->bg);
24100 textout_ex(screen,font,"5",d->x,d->y+24,d->fg,d->bg);
24101
24102 for(int32_t i=0; i<32; i++)
24103 {
24104 int32_t px2 = d->x+((i&15)<<3)+8;
24105 int32_t py2 = d->y+((i>>4)<<3)+8;
24106 rectfill(screen,px2,py2,px2+7,py2+7,i);
24107 }
24108
24109 for(int32_t i=0; i<16; i++)
24110 {
24111 int32_t px2 = d->x+(i<<3)+8;
24112 rectfill(screen,px2,d->y+24,px2+7,d->y+31,i+80);
24113 }
24114 }
24115
24116 return D_O_K;
24117 }
24118
24119 int32_t hexclicked=-1;
24120
24121 int32_t d_misccolors_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
24122 {
24123 switch(msg)
24124 {
24125 case MSG_GOTFOCUS:
24126 hexclicked=((int32_t)(size_t)(d->dp3))+20;
24127 break;
24128
24129 case MSG_LOSTFOCUS:
24130 hexclicked=-1;
24131 break;
24132 }
24133
24134 return d_hexedit_proc(msg,d,c);
24135 }
24136
24137
24138 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c);
24139
24140 static int32_t misccolor1_list[] =
24141 {
24142 // dialog control number
24143 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 36, 37, 38, 39, 40, -1
24144 };
24145
24146 static int32_t misccolor2_list[] =
24147 {
24148 // dialog control number
24149 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 41, 42, 43, 44, 45, -1
24150 };
24151
24152 static int32_t misccolor3_list[] =
24153 {
24154 // dialog control number
24155 14, 15, 16, 17, 18, 30, 31, 32, 33, 34, 46, 47, 48, 49, 50, -1
24156 };
24157
24158 static int32_t misccolor4_list[] =
24159 {
24160 19, 35, 51, 54, 55, 56, -1
24161 };
24162
24163 static TABPANEL misccolor_tabs[] =
24164 {
24165 // (text)
24166 { (char *)"1", D_SELECTED, misccolor1_list, 0, NULL },
24167 { (char *)"2", 0, misccolor2_list, 0, NULL },
24168 { (char *)"3", 0, misccolor3_list, 0, NULL },
24169 { (char *)"4", 0, misccolor4_list, 0, NULL },
24170 { NULL, 0, NULL, 0, NULL }
24171 };
24172
24173 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c);
24174
24175 static DIALOG misccolors_dlg[] =
24176 {
24177 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
24178 9 { jwin_win_proc, 2, 21, 316, 197-23, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Misc Colors", NULL, NULL },
24179 // { jwin_frame_proc, 98-84+1+2, 52+8-6+4, 132, 100, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
24180 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24181 9 { d_misccolors_proc, 92-84+1+2, 44+8-6+4, 128+8, 96+8, vc(9), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
24182 //3
24183 9 { d_misccolors_tab_proc, 150+14-2+10-15, 60-14, 150-10+15, 144-20-10, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) misccolor_tabs, NULL, (void *)misccolors_dlg },
24184 //4
24185 9 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Text:", NULL, NULL },
24186 9 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Caption:", NULL, NULL },
24187 9 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Overworld Minmap:", NULL, NULL },
24188 9 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Background:", NULL, NULL },
24189 9 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 1:", NULL, NULL },
24190 9 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 2:", NULL, NULL },
24191 9 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Dark:", NULL, NULL },
24192 9 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Goal:", NULL, NULL },
24193 9 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Light):", NULL, NULL },
24194 9 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Dark):", NULL, NULL },
24195 9 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Background:", NULL, NULL },
24196 9 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Shadow:", NULL, NULL },
24197 9 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Triforce Frame:", NULL, NULL },
24198 9 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Background:", NULL, NULL },
24199 9 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Foreground:", NULL, NULL },
24200 9 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Player's Position:", NULL, NULL },
24201
24202 //20
24203 9 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)0, },
24204 9 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)1, },
24205 9 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)2, },
24206 9 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)3, },
24207 9 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)4, },
24208 9 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)5, },
24209 9 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)6, },
24210 9 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)7, },
24211 9 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)8, },
24212 9 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)9, },
24213 9 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)10, },
24214 9 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)11, },
24215 9 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)12, },
24216 9 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)13, },
24217 9 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)14, },
24218 9 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)15, },
24219
24220 //36
24221 9 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24222 9 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24223 9 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24224 9 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24225 9 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24226 9 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24227 9 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24228 9 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24229 9 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24230 9 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24231 9 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24232 9 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24233 9 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24234 9 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24235 9 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24236 9 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24237
24238 //52
24239 9 { jwin_button_proc, 90, 190-20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24240 9 { jwin_button_proc, 170, 190-20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24241 9 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Message Text:", NULL, NULL },
24242 9 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)35, },
24243 9 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
24244 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24245 };
24246
24247 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c)
24248 {
24249
24250 switch(msg)
24251 {
24252 case MSG_WANTFOCUS:
24253 return D_WANTFOCUS;
24254 break;
24255 }
24256
24257 return jwin_tab_proc(msg,d,c);
24258 }
24259
24260
24261 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c)
24262 {
24263 //these are here to bypass compiler warnings about unused arguments
24264 c=c;
24265 int32_t mul=12;
24266
24267 switch(msg)
24268 {
24269 case MSG_CLICK:
24270 if(hexclicked!=-1)
24271 {
24272 int32_t color_col=vbound(((gui_mouse_x()-d->x-8)/mul),0,15);
24273 int32_t color_row=vbound(((gui_mouse_y()-d->y-10)/mul),0,11);
24274 sprintf((char*)misccolors_dlg[hexclicked].dp,"%X%X",color_row,color_col);
24275 object_message(misccolors_dlg+hexclicked,MSG_DRAW,0);
24276 }
24277
24278 break;
24279
24280 case MSG_DRAW:
24281 for(int32_t i=0; i<10; i++)
24282 {
24283 textprintf_centre_ex(screen,font,d->x+8+4+(i*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
24284 }
24285
24286 for(int32_t i=0; i<6; i++)
24287 {
24288 textprintf_centre_ex(screen,font,d->x+8+4+((10+i)*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
24289 }
24290
24291 for(int32_t i=0; i<10; i++)
24292 {
24293 textprintf_right_ex(screen,font,d->x+6,d->y+(i*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
24294 }
24295
24296 for(int32_t i=0; i<2; i++)
24297 {
24298 textprintf_right_ex(screen,font,d->x+6,d->y+((i+10)*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
24299 }
24300
24301 jwin_draw_frame(screen,d->x+6,d->y+8,int32_t(132*1.5)-2,int32_t(100*1.5)-2,FR_DEEP);
24302
24303 for(int32_t i=0; i<192; i++)
24304 {
24305 int32_t px2 = d->x+int32_t(((i&15)<<3)*1.5)+8;
24306 int32_t py2 = d->y+int32_t(((i>>4)<<3)*1.5)+8+2;
24307 rectfill(screen,px2,py2,px2+(mul-1),py2+(mul-1),i);
24308 }
24309
24310 break;
24311 }
24312
24313 return D_O_K;
24314 }
24315
24316
24317 int32_t onMiscColors()
24318 {
24319 char buf[17][3];
24320 byte *si = &(QMisc.colors.text);
24321 misccolors_dlg[0].dp2=get_zc_font(font_lfont);
24322
24323 for(int32_t i=0; i<16; i++)
24324 {
24325 sprintf(buf[i],"%02X",*(si++));
24326 sprintf(buf[16], "%02X", QMisc.colors.msgtext);
24327 misccolors_dlg[i+20].dp = buf[i];
24328 misccolors_dlg[55].dp = buf[16];
24329 }
24330
24331 large_dialog(misccolors_dlg);
24332
24333 if(do_zqdialog(misccolors_dlg,0)==52)
24334 {
24335 saved=false;
24336 si = &(QMisc.colors.text);
24337
24338 for(int32_t i=0; i<16; i++)
24339 {
24340 *si = zc_xtoi(buf[i]);
24341 ++si;
24342 }
24343
24344 QMisc.colors.msgtext = zc_xtoi(buf[16]);
24345 }
24346
24347 return D_O_K;
24348 }
24349
24350 // **** Palette cycling ****
24351
24352 static int32_t palclk[3];
24353 static int32_t palpos[3];
24354
24355 26 void reset_pal_cycling()
24356 {
24357
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 26 times.
104 for(int32_t i=0; i<3; i++)
24358 78 palclk[i]=palpos[i]=0;
24359 26 }
24360
24361 void cycle_palette()
24362 {
24363 if(!get_qr(qr_FADE))
24364 return;
24365
24366 int32_t level = Map.CurrScr()->color;
24367 bool refreshpal = false;
24368
24369 for(int32_t i=0; i<3; i++)
24370 {
24371 palcycle c = QMisc.cycles[level][i];
24372
24373 if(c.count&0xF0)
24374 {
24375 if(++palclk[i] >= c.speed)
24376 {
24377 palclk[i]=0;
24378
24379 if(++palpos[i] >= (c.count>>4))
24380 palpos[i]=0;
24381
24382 byte *si = colordata + CSET(level*pdLEVEL+poFADE1+1+palpos[i])*3;
24383
24384 si += (c.first&15)*3;
24385
24386 for(int32_t col=c.first&15; col<=(c.count&15); col++)
24387 {
24388 RAMpal[CSET(c.first>>4)+col] = _RGB(si);
24389 si+=3;
24390 }
24391
24392 refreshpal = true;
24393 }
24394 }
24395 }
24396
24397 if(refreshpal)
24398 {
24399 rebuild_trans_table();
24400 zc_set_palette_range(RAMpal,0,192,false);
24401 }
24402 }
24403
24404
24405 void doHelp()
24406 {
24407 do_box_edit(helpstr, "ZQuest Help", true, true);
24408 }
24409
24410 int32_t onHelp()
24411 {
24412 restore_mouse();
24413 doHelp();
24414 return D_O_K;
24415 }
24416
24417 void doZstringshelp()
24418 {
24419 do_box_edit(zstringshelpstr, "ZStrings Help", true, true);
24420 }
24421
24422 int32_t onZstringshelp()
24423 {
24424 restore_mouse();
24425 doZstringshelp();
24426 return D_O_K;
24427 }
24428
24429 static DIALOG layerdata_dlg[] =
24430 {
24431 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
24432 { jwin_win_proc, 16-12, 20+32, 288+1+24, 200+1-32-16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Layer Data", NULL, NULL },
24433 { jwin_button_proc, 170, 180, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24434 { jwin_button_proc, 90, 180, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24435 // 3
24436 { jwin_rtext_proc, 72, 88, 40, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Map:", NULL, NULL },
24437 { jwin_rtext_proc, 72, 88+18, 48, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
24438 { jwin_rtext_proc, 72, 88+36, 56, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Transparent:", NULL, NULL },
24439 { jwin_ctext_proc, 89, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
24440 { jwin_ctext_proc, 89+40, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
24441 { jwin_ctext_proc, 89+80, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
24442 { jwin_ctext_proc, 89+120, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
24443 { jwin_ctext_proc, 89+160, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
24444 { jwin_ctext_proc, 89+200, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
24445
24446 //12
24447 { jwin_edit_proc, 76, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24448 { d_hexedit_proc, 76, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24449 { jwin_check_proc, 76, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24450
24451 { jwin_edit_proc, 76+40, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24452 { d_hexedit_proc, 76+40, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24453 { jwin_check_proc, 76+40, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24454
24455 { jwin_edit_proc, 76+80, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24456 { d_hexedit_proc, 76+80, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24457 { jwin_check_proc, 76+80, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24458
24459 { jwin_edit_proc, 76+120, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24460 { d_hexedit_proc, 76+120, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24461 { jwin_check_proc, 76+120, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24462
24463 { jwin_edit_proc, 76+160, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24464 { d_hexedit_proc, 76+160, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24465 { jwin_check_proc, 76+160, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24466
24467 { jwin_edit_proc, 76+200, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24468 { d_hexedit_proc, 76+200, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
24469 { jwin_check_proc, 76+200, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
24470
24471 //30
24472 { jwin_button_proc, 76, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24473 { jwin_button_proc, 76+40, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24474 { jwin_button_proc, 76+80, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24475 { jwin_button_proc, 76+120, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24476 { jwin_button_proc, 76+160, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24477 { jwin_button_proc, 76+200, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
24478
24479 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24480 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24481
24482 };
24483
24484 int32_t edit_layers(mapscr* tempscr)
24485 {
24486 char buf[6][2][8];
24487 layerdata_dlg[0].dp2 = get_zc_font(font_lfont);
24488
24489 for(int32_t x=0; x<6; x++)
24490 {
24491 sprintf(buf[x][0],"%d",tempscr->layermap[x]);
24492 sprintf(buf[x][1],"%02X",tempscr->layerscreen[x]);
24493 }
24494
24495 for(int32_t x=0; x<6; x++)
24496 {
24497 for(int32_t y=0; y<2; y++)
24498 {
24499 layerdata_dlg[(x*3)+y+12].dp = buf[x][y];
24500 }
24501 }
24502
24503 for(int32_t x=0; x<6; x++)
24504 {
24505 layerdata_dlg[(x*3)+2+12].flags = (tempscr->layeropacity[x]<255) ? D_SELECTED : 0;
24506 }
24507
24508 large_dialog(layerdata_dlg);
24509
24510 int32_t ret=do_zqdialog(layerdata_dlg,0);
24511
24512 if(ret>=2)
24513 {
24514 for(int32_t x=0; x<6; x++)
24515 {
24516
24517 tempscr->layermap[x]=atoi(buf[x][0]);
24518
24519 if(tempscr->layermap[x]>map_count)
24520 {
24521 tempscr->layermap[x]=0;
24522 }
24523
24524 tempscr->layerscreen[x]=zc_xtoi(buf[x][1]);
24525
24526 if(zc_xtoi(buf[x][1])>=MAPSCRS)
24527 {
24528 tempscr->layerscreen[x]=0;
24529 }
24530
24531 // tempscr->layeropacity[x]=layerdata_dlg[(x*9)+8+19].flags & D_SELECTED ? 128:255;
24532 tempscr->layeropacity[x]=layerdata_dlg[(x*3)+2+12].flags & D_SELECTED ? 128:255;
24533 }
24534
24535 // } else if (ret>72&&ret<79) {
24536 // return (ret-72);
24537 }
24538
24539 return ret;
24540 }
24541
24542 static DIALOG autolayer_dlg[] =
24543 {
24544 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
24545 { jwin_win_proc, 64, 32+48, 192+1, 184+1-64, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Autolayer Setup", NULL, NULL },
24546 { jwin_text_proc, 76, 56+48, 136, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map for layer ?: ", NULL, NULL },
24547 { jwin_edit_proc, 212, 56+48, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
24548 { jwin_check_proc, 76, 56+18+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Screens", NULL, NULL },
24549 { jwin_button_proc, 90, 188-12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
24550
24551 //5
24552 { jwin_button_proc, 170, 188-12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
24553 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
24554 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
24555 { jwin_check_proc, 76, 56+28+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Layers", NULL, NULL },
24556 { jwin_check_proc, 76, 56+38+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Overwrite Layers", NULL, NULL },
24557
24558 //10
24559 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
24560 };
24561 enum
24562 {
24563 autolyr_blankscreens,
24564 autolyr_blanklayers,
24565 autolyr_any
24566 };
24567 void autolayer(mapscr* tempscr, int32_t layer, int32_t al[6][3])
24568 {
24569 char tbuf[80],mlayer[80];
24570 autolayer_dlg[0].dp2=get_zc_font(font_lfont);
24571 sprintf(tbuf, "Map for layer %d: ", layer+1);
24572 autolayer_dlg[1].dp=tbuf;
24573 sprintf(mlayer, "%d", tempscr->layermap[layer]);
24574 autolayer_dlg[2].dp=mlayer;
24575
24576 large_dialog(autolayer_dlg);
24577 int ret, sel = 8, fl = autolyr_blanklayers;
24578 bool running = true;
24579 do
24580 {
24581 SETFLAG(autolayer_dlg[3].flags, D_SELECTED, sel==3);
24582 SETFLAG(autolayer_dlg[8].flags, D_SELECTED, sel==8);
24583 SETFLAG(autolayer_dlg[9].flags, D_SELECTED, sel==9);
24584 switch(ret=do_zqdialog(autolayer_dlg,0))
24585 {
24586 case 4: //OK
24587 {
24588 int32_t lmap=vbound(atoi(mlayer),0,Map.getMapCount());
24589 al[layer][0]=lmap;
24590 tempscr->layermap[layer]=lmap;
24591 tempscr->layerscreen[layer]=Map.getCurrScr();
24592 al[layer][1]=fl;
24593 al[layer][2]=1;
24594 running = false;
24595 break;
24596 }
24597 case 0: case 5: //cancel
24598 running = false;
24599 break;
24600 case 3:
24601 sel = ret;
24602 fl = autolyr_blankscreens;
24603 break;
24604 case 8:
24605 sel = ret;
24606 fl = autolyr_blanklayers;
24607 break;
24608 case 9:
24609 sel = ret;
24610 fl = autolyr_any;
24611 break;
24612 }
24613 }
24614 while(ret != 0 && ret != 4 && ret != 5);
24615 }
24616
24617 int32_t onLayers()
24618 {
24619 mapscr tempscr=*Map.CurrScr();
24620 int32_t al[6][3]; //autolayer[layer][0=map, 1=autolyr_ type, 2=bool go]
24621
24622 for(int32_t i=0; i<6; i++)
24623 {
24624 al[i][0]=tempscr.layermap[i];
24625 al[i][1]=0;
24626 al[i][2]=0;
24627 }
24628
24629 int32_t ret;
24630
24631 do
24632 {
24633 ret=edit_layers(&tempscr);
24634
24635 if(ret>2) //autolayer button
24636 {
24637 autolayer(&tempscr, ret-30, al);
24638 }
24639 }
24640 while(ret>2); //autolayer button
24641
24642 if(ret==2) //OK
24643 {
24644 saved=false;
24645 TheMaps[Map.getCurrMap()*MAPSCRS+Map.getCurrScr()]=tempscr;
24646
24647 for(int32_t i=0; i<6; i++)
24648 {
24649 int32_t tm=tempscr.layermap[i]-1;
24650 int32_t ts=tempscr.layerscreen[i];
24651
24652 if(al[i][2])
24653 {
24654 map_autolayers[Map.getCurrMap()*6+i] = al[i][0];
24655 for(int32_t j=0; j<128; j++)
24656 {
24657 auto& curmapscr = TheMaps[Map.getCurrMap()*MAPSCRS+j];
24658 if(al[i][1] == autolyr_blankscreens && (curmapscr.valid&mVALID))
24659 continue;
24660 else if(al[i][1] == autolyr_blanklayers && curmapscr.layermap[i])
24661 continue;
24662
24663 curmapscr.layermap[i]=al[i][0];
24664 curmapscr.layerscreen[i]=al[i][0]?j:0;
24665 }
24666 }
24667 }
24668 }
24669
24670 // Check that the working layer wasn't just disabled
24671 if(CurrentLayer>0 && tempscr.layermap[CurrentLayer-1]==0)
24672 CurrentLayer=0;
24673
24674 return D_O_K;
24675 }
24676
24677
24678 char *itoa(int32_t i)
24679 {
24680 static char itoaret[500];
24681 sprintf(itoaret, "%d", i);
24682 return itoaret;
24683 }
24684
24685 64 void fps_callback()
24686 {
24687 64 lastfps=framecnt;
24688 64 framecnt=0;
24689 64 }
24690
24691 END_OF_FUNCTION(fps_callback)
24692
24693 //uint32_t col_diff[3*128];
24694 /*
24695 void bestfit_init(void)
24696 {
24697 int32_t i;
24698
24699 for (i=1; i<64; i++)
24700
24701 {
24702 int32_t k = i * i;
24703 col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59);
24704 col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30);
24705 col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11);
24706 }
24707 }
24708 */
24709 16 void create_rgb_table2(RGB_MAP *table, AL_CONST PALETTE pal_8bit, void (*callback)(int32_t pos))
24710 {
24711 #define UNUSED 65535
24712 #define LAST 65532
24713
24714 // Allegro has been modified to use an 8 bit palette, but this method and RGB_MAP still use 6 bit.
24715 PALETTE pal;
24716
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for (int i = 0; i < 256; i++)
24717 {
24718 4096 pal[i] = pal_8bit[i];
24719 4096 pal[i].r /= 4;
24720 4096 pal[i].g /= 4;
24721 4096 pal[i].b /= 4;
24722 4096 }
24723
24724 /* macro add adds to single linked list */
24725 #define add(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
24726 (first != LAST ? (next[last] = (i)) : (first = (i))), \
24727 (last = (i))) : 0)
24728
24729 /* same but w/o checking for first element */
24730 #define add1(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
24731 next[last] = (i), \
24732 (last = (i))) : 0)
24733 /* calculates distance between two colors */
24734 #define dist(a1, a2, a3, b1, b2, b3) \
24735 (col_diff[ ((a2) - (b2)) & 0x7F] + \
24736 (col_diff + 128)[((a1) - (b1)) & 0x7F] + \
24737 (col_diff + 256)[((a3) - (b3)) & 0x7F])
24738
24739 /* converts r,g,b to position in array and back */
24740 #define pos(r, g, b) \
24741 (((r) / 2) * 32 * 32 + ((g) / 2) * 32 + ((b) / 2))
24742
24743 #define depos(pal, r, g, b) \
24744 ((b) = ((pal) & 31) * 2, \
24745 (g) = (((pal) >> 5) & 31) * 2, \
24746 (r) = (((pal) >> 10) & 31) * 2)
24747
24748 /* is current color better than pal1? */
24749 #define better(r1, g1, b1, pal1) \
24750 (((int32_t)dist((r1), (g1), (b1), \
24751 (pal1).r, (pal1).g, (pal1).b)) > (int32_t)dist2)
24752
24753 /* checking of position */
24754 #define dopos(rp, gp, bp, ts) \
24755 if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \
24756 (gp > -1 || g > 0) && (gp < 1 || g < 61) && \
24757 (bp > -1 || b > 0) && (bp < 1 || b < 61)) \
24758 { \
24759 i = first + rp * 32 * 32 + gp * 32 + bp; \
24760 if (!data[i]) \
24761 { \
24762 data[i] = val; \
24763 add1(i); \
24764 } \
24765 else if ((ts) && (data[i] != val)) \
24766 { \
24767 dist2 = (rp ? (col_diff+128)[(r+2*rp-pal[val].r) & 0x7F] : r2) + \
24768 (gp ? (col_diff )[(g+2*gp-pal[val].g) & 0x7F] : g2) + \
24769 (bp ? (col_diff+256)[(b+2*bp-pal[val].b) & 0x7F] : b2); \
24770 if (better((r+2*rp), (g+2*gp), (b+2*bp), pal[data[i]])) \
24771 { \
24772 data[i] = val; \
24773 add1(i); \
24774 } \
24775 } \
24776 }
24777
24778 int32_t i, curr, r, g, b, val, dist2;
24779 uint32_t r2, g2, b2;
24780 uint16_t next[32*32*32];
24781 uint8_t *data;
24782 16 int32_t first = LAST;
24783 16 int32_t last = LAST;
24784 16 int32_t count = 0;
24785 16 int32_t cbcount = 0;
24786
24787 #define AVERAGE_COUNT 18000
24788
24789
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(col_diff[1] == 0)
24790 9 bestfit_init();
24791
24792 16 memset(next, 255, sizeof(next));
24793 16 memset(table->data, 0, sizeof(char)*32*32*32);
24794
24795
24796 16 data = (uint8_t *)table->data;
24797
24798 /* add starting seeds for floodfill */
24799
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 for(i=1; i<PAL_SIZE; i++)
24800 {
24801 4080 curr = pos(pal[i].r, pal[i].g, pal[i].b);
24802
24803
2/2
✓ Branch 0 taken 3281 times.
✓ Branch 1 taken 799 times.
4080 if(next[curr] == UNUSED)
24804 {
24805 799 data[curr] = i;
24806
3/4
✓ Branch 0 taken 799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✓ Branch 3 taken 16 times.
799 add(curr);
24807 799 }
24808 4080 }
24809
24810 /* main floodfill: two versions of loop for faster growing in blue axis */
24811 // while (first != LAST) {
24812
2/2
✓ Branch 0 taken 345346 times.
✓ Branch 1 taken 16 times.
345362 while(first < LAST)
24813 {
24814 345346 depos(first, r, g, b);
24815
24816 /* calculate distance of current color */
24817 345346 val = data[first];
24818 345346 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
24819 345346 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
24820 345346 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
24821
24822 /* try to grow to all directions */
24823 #ifdef _MSC_VER
24824 #pragma warning(disable:4127)
24825 #endif
24826
11/12
✓ Branch 0 taken 11235 times.
✓ Branch 1 taken 334111 times.
✓ Branch 2 taken 320687 times.
✓ Branch 3 taken 13424 times.
✓ Branch 4 taken 13424 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 269728 times.
✓ Branch 7 taken 50959 times.
✓ Branch 8 taken 13298 times.
✓ Branch 9 taken 37661 times.
✓ Branch 10 taken 24398 times.
✓ Branch 11 taken 13263 times.
666033 dopos(0, 0, 1, 1);
24827
11/12
✓ Branch 0 taken 10141 times.
✓ Branch 1 taken 335205 times.
✓ Branch 2 taken 323487 times.
✓ Branch 3 taken 11718 times.
✓ Branch 4 taken 11718 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 282552 times.
✓ Branch 7 taken 40935 times.
✓ Branch 8 taken 15125 times.
✓ Branch 9 taken 25810 times.
✓ Branch 10 taken 17769 times.
✓ Branch 11 taken 8041 times.
668833 dopos(0, 0,-1, 1);
24828
11/12
✓ Branch 0 taken 11084 times.
✓ Branch 1 taken 334262 times.
✓ Branch 2 taken 325729 times.
✓ Branch 3 taken 8533 times.
✓ Branch 4 taken 8533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 269857 times.
✓ Branch 7 taken 55872 times.
✓ Branch 8 taken 35827 times.
✓ Branch 9 taken 20045 times.
✓ Branch 10 taken 12843 times.
✓ Branch 11 taken 7202 times.
671075 dopos(1, 0, 0, 1);
24829
11/12
✓ Branch 0 taken 11218 times.
✓ Branch 1 taken 334128 times.
✓ Branch 2 taken 325496 times.
✓ Branch 3 taken 8632 times.
✓ Branch 4 taken 8632 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 271953 times.
✓ Branch 7 taken 53543 times.
✓ Branch 8 taken 35355 times.
✓ Branch 9 taken 18188 times.
✓ Branch 10 taken 11951 times.
✓ Branch 11 taken 6237 times.
670842 dopos(-1, 0, 0, 1);
24830
11/12
✓ Branch 0 taken 11196 times.
✓ Branch 1 taken 334150 times.
✓ Branch 2 taken 300495 times.
✓ Branch 3 taken 33655 times.
✓ Branch 4 taken 33655 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 228178 times.
✓ Branch 7 taken 72317 times.
✓ Branch 8 taken 59058 times.
✓ Branch 9 taken 13259 times.
✓ Branch 10 taken 8804 times.
✓ Branch 11 taken 4455 times.
645841 dopos(0, 1, 0, 1);
24831
11/12
✓ Branch 0 taken 9995 times.
✓ Branch 1 taken 335351 times.
✓ Branch 2 taken 306085 times.
✓ Branch 3 taken 29266 times.
✓ Branch 4 taken 29266 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 234420 times.
✓ Branch 7 taken 71665 times.
✓ Branch 8 taken 60356 times.
✓ Branch 9 taken 11309 times.
✓ Branch 10 taken 7204 times.
✓ Branch 11 taken 4105 times.
651431 dopos(0,-1, 0, 1);
24832 #ifdef _MSC_VER
24833 #pragma warning(default:4127)
24834 #endif
24835
24836 /* faster growing of blue direction */
24837
4/4
✓ Branch 0 taken 335205 times.
✓ Branch 1 taken 10141 times.
✓ Branch 2 taken 15125 times.
✓ Branch 3 taken 320080 times.
345346 if((b > 0) && (data[first-1] == val))
24838 {
24839 320080 b -= 2;
24840 320080 first--;
24841 320080 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
24842
24843 #ifdef _MSC_VER
24844 #pragma warning(disable:4127)
24845 #endif
24846
5/6
✓ Branch 0 taken 10465 times.
✓ Branch 1 taken 309615 times.
✓ Branch 2 taken 282231 times.
✓ Branch 3 taken 27384 times.
✓ Branch 4 taken 27384 times.
✗ Branch 5 not taken.
602311 dopos(-1, 0, 0, 0);
24847
5/6
✓ Branch 0 taken 10357 times.
✓ Branch 1 taken 309723 times.
✓ Branch 2 taken 281539 times.
✓ Branch 3 taken 28184 times.
✓ Branch 4 taken 28184 times.
✗ Branch 5 not taken.
601619 dopos(1, 0, 0, 0);
24848
5/6
✓ Branch 0 taken 9331 times.
✓ Branch 1 taken 310749 times.
✓ Branch 2 taken 273440 times.
✓ Branch 3 taken 37309 times.
✓ Branch 4 taken 37309 times.
✗ Branch 5 not taken.
593520 dopos(0,-1, 0, 0);
24849
5/6
✓ Branch 0 taken 10479 times.
✓ Branch 1 taken 309601 times.
✓ Branch 2 taken 260036 times.
✓ Branch 3 taken 49565 times.
✓ Branch 4 taken 49565 times.
✗ Branch 5 not taken.
580116 dopos(0, 1, 0, 0);
24850 #ifdef _MSC_VER
24851 #pragma warning(default:4127)
24852 #endif
24853
24854 320080 first++;
24855 320080 }
24856
24857 /* get next from list */
24858 345346 i = first;
24859 345346 first = next[first];
24860 345346 next[i] = UNUSED;
24861
24862 /* second version of loop */
24863 // if (first != LAST) {
24864
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 345338 times.
345346 if(first < LAST)
24865 {
24866
24867 345338 depos(first, r, g, b);
24868
24869 345338 val = data[first];
24870 345338 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
24871 345338 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
24872 345338 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
24873
24874 #ifdef _MSC_VER
24875 #pragma warning(disable:4127)
24876 #endif
24877
11/12
✓ Branch 0 taken 10849 times.
✓ Branch 1 taken 334489 times.
✓ Branch 2 taken 318832 times.
✓ Branch 3 taken 15657 times.
✓ Branch 4 taken 15657 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 267637 times.
✓ Branch 7 taken 51195 times.
✓ Branch 8 taken 13403 times.
✓ Branch 9 taken 37792 times.
✓ Branch 10 taken 24453 times.
✓ Branch 11 taken 13339 times.
664170 dopos(0, 0, 1, 1);
24878
11/12
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 335295 times.
✓ Branch 2 taken 325366 times.
✓ Branch 3 taken 9929 times.
✓ Branch 4 taken 9929 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 284407 times.
✓ Branch 7 taken 40959 times.
✓ Branch 8 taken 15393 times.
✓ Branch 9 taken 25566 times.
✓ Branch 10 taken 17721 times.
✓ Branch 11 taken 7845 times.
670704 dopos(0, 0,-1, 1);
24879
11/12
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 334105 times.
✓ Branch 2 taken 325344 times.
✓ Branch 3 taken 8761 times.
✓ Branch 4 taken 8761 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 269241 times.
✓ Branch 7 taken 56103 times.
✓ Branch 8 taken 36025 times.
✓ Branch 9 taken 20078 times.
✓ Branch 10 taken 12868 times.
✓ Branch 11 taken 7210 times.
670682 dopos(1, 0, 0, 1);
24880
11/12
✓ Branch 0 taken 11062 times.
✓ Branch 1 taken 334276 times.
✓ Branch 2 taken 325829 times.
✓ Branch 3 taken 8447 times.
✓ Branch 4 taken 8447 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272185 times.
✓ Branch 7 taken 53644 times.
✓ Branch 8 taken 35555 times.
✓ Branch 9 taken 18089 times.
✓ Branch 10 taken 12192 times.
✓ Branch 11 taken 5897 times.
671167 dopos(-1, 0, 0, 1);
24881
11/12
✓ Branch 0 taken 11199 times.
✓ Branch 1 taken 334139 times.
✓ Branch 2 taken 301102 times.
✓ Branch 3 taken 33037 times.
✓ Branch 4 taken 33037 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 229160 times.
✓ Branch 7 taken 71942 times.
✓ Branch 8 taken 58839 times.
✓ Branch 9 taken 13103 times.
✓ Branch 10 taken 8762 times.
✓ Branch 11 taken 4341 times.
646440 dopos(0, 1, 0, 1);
24882
11/12
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 335482 times.
✓ Branch 2 taken 307229 times.
✓ Branch 3 taken 28253 times.
✓ Branch 4 taken 28253 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 235052 times.
✓ Branch 7 taken 72177 times.
✓ Branch 8 taken 60822 times.
✓ Branch 9 taken 11355 times.
✓ Branch 10 taken 7431 times.
✓ Branch 11 taken 3924 times.
652567 dopos(0,-1, 0, 1);
24883 #ifdef _MSC_VER
24884 #pragma warning(default:4127)
24885 #endif
24886
24887
4/4
✓ Branch 0 taken 334489 times.
✓ Branch 1 taken 10849 times.
✓ Branch 2 taken 13403 times.
✓ Branch 3 taken 321086 times.
345338 if((b < 61) && (data[first + 1] == val))
24888 {
24889 321086 b += 2;
24890 321086 first++;
24891 321086 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7f];
24892 #ifdef _MSC_VER
24893 #pragma warning(disable:4127)
24894 #endif
24895
5/6
✓ Branch 0 taken 10359 times.
✓ Branch 1 taken 310727 times.
✓ Branch 2 taken 279937 times.
✓ Branch 3 taken 30790 times.
✓ Branch 4 taken 30790 times.
✗ Branch 5 not taken.
601023 dopos(-1, 0, 0, 0);
24896
5/6
✓ Branch 0 taken 10453 times.
✓ Branch 1 taken 310633 times.
✓ Branch 2 taken 272244 times.
✓ Branch 3 taken 38389 times.
✓ Branch 4 taken 38389 times.
✗ Branch 5 not taken.
593330 dopos(1, 0, 0, 0);
24897
5/6
✓ Branch 0 taken 9151 times.
✓ Branch 1 taken 311935 times.
✓ Branch 2 taken 260731 times.
✓ Branch 3 taken 51204 times.
✓ Branch 4 taken 51204 times.
✗ Branch 5 not taken.
581817 dopos(0,-1, 0, 0);
24898
5/6
✓ Branch 0 taken 10599 times.
✓ Branch 1 taken 310487 times.
✓ Branch 2 taken 259135 times.
✓ Branch 3 taken 51352 times.
✓ Branch 4 taken 51352 times.
✗ Branch 5 not taken.
580221 dopos(0, 1, 0, 0);
24899 #ifdef _MSC_VER
24900 #pragma warning(default:4127)
24901 #endif
24902
24903 321086 first--;
24904 321086 }
24905
24906 345338 i = first;
24907 345338 first = next[first];
24908 345338 next[i] = UNUSED;
24909 345338 }
24910
24911 345346 count++;
24912
24913
2/2
✓ Branch 0 taken 341234 times.
✓ Branch 1 taken 4112 times.
345346 if(count == (cbcount+1)*AVERAGE_COUNT/256)
24914 {
24915
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 if(cbcount < 256)
24916 {
24917
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(callback)
24918 callback(cbcount);
24919
24920 4096 cbcount++;
24921 4096 }
24922 4112 }
24923
24924 }
24925
24926 /* only the transparent (pink) color can be mapped to index 0 */
24927
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if((pal[0].r == 63) && (pal[0].g == 0) && (pal[0].b == 63))
24928 table->data[31][0][31] = 0;
24929
24930
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(callback)
24931 while(cbcount < 256)
24932 callback(cbcount++);
24933 16 }
24934
24935 16 void rebuild_trans_table()
24936 {
24937 16 create_rgb_table2(&zq_rgb_table, RAMpal, NULL);
24938 16 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
24939 16 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
24940
24941
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t q=0; q<PAL_SIZE; q++)
24942 {
24943 4096 trans_table2.data[0][q] = q;
24944 4096 trans_table2.data[q][q] = q;
24945 4096 }
24946 16 }
24947
24948 int32_t isFullScreen()
24949 {
24950 return !is_windowed_mode();
24951 }
24952
24953 void hit_close_button()
24954 {
24955 close_button_quit=true;
24956 return;
24957 }
24958
24959 extern bool dirty_screen;
24960
24961 void anim_hw_screen(bool force)
24962 {
24963 // if (force || myvsync)
24964 {
24965 ++cpoolbrush_index;
24966
24967 if(prv_mode)
24968 {
24969 if(Map.get_prvtime())
24970 {
24971 Map.set_prvtime(Map.get_prvtime()-1);
24972
24973 if(!Map.get_prvtime())
24974 {
24975 prv_warp=1;
24976 }
24977 }
24978 }
24979 if(AnimationOn)
24980 {
24981 animate_combos();
24982 update_freeform_combos();
24983 }
24984
24985 if(CycleOn)
24986 cycle_palette();
24987
24988 animate_coords();
24989 update_hw_screen();
24990 }
24991 }
24992
24993 void custom_vsync()
24994 {
24995 anim_hw_screen(true);
24996 }
24997
24998 void switch_out()
24999 {
25000 zcmusic_pause(zcmusic, ZCM_PAUSE);
25001 zc_midi_pause();
25002 }
25003
25004 void switch_in()
25005 {
25006 if(exiting_program)
25007 return;
25008 zcmusic_pause(zcmusic, ZCM_RESUME);
25009 zc_midi_resume();
25010 }
25011
25012 void Z_eventlog(const char *format,...)
25013 {
25014 format=format; //to prevent a compiler warning
25015 }
25016
25017 int32_t get_currdmap()
25018 {
25019 return zinit.start_dmap;
25020 }
25021
25022 int32_t get_dlevel()
25023 {
25024 return DMaps[zinit.start_dmap].level;
25025 }
25026
25027 int32_t get_currscr()
25028 {
25029 return Map.getCurrScr();
25030 }
25031
25032 int32_t get_currmap()
25033 {
25034 return Map.getCurrMap();
25035 }
25036
25037 int32_t get_homescr()
25038 {
25039 return DMaps[zinit.start_dmap].cont;
25040 }
25041
25042 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
25043 {
25044 //TODO remove as special case?? -DD
25045 if(item_type==itype_shield)
25046 {
25047 return 2;
25048 }
25049
25050 int id = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
25051 return id > -1 ? itemsbuf[id].fam_type : 0;
25052 }
25053
25054 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
25055 {
25056 if (game)
25057 {
25058 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
25059 return (result<0) ? 0 : itemsbuf[result].power;
25060 }
25061 return 1;
25062 }
25063
25064 int32_t current_item_id(int32_t itemtype, bool, bool, bool)
25065 {
25066 if (game)
25067 {
25068 int32_t result = -1;
25069 int32_t highestlevel = -1;
25070
25071 for (int32_t i = 0; i < MAXITEMS; i++)
25072 {
25073 if ((zq_ignore_item_ownership || game->get_item(i)) && itemsbuf[i].family == itemtype)
25074 {
25075 if (itemsbuf[i].fam_type >= highestlevel)
25076 {
25077 highestlevel = itemsbuf[i].fam_type;
25078 result = i;
25079 }
25080 }
25081 }
25082 return result;
25083 }
25084 for(int32_t i=0; i<MAXITEMS; i++)
25085 {
25086 if(itemsbuf[i].family==itemtype)
25087 return i;
25088 }
25089
25090 return -1;
25091 }
25092
25093
25094 bool can_use_item(int32_t item_type, int32_t item)
25095 {
25096 //these are here to bypass compiler warnings about unused arguments
25097 item_type=item_type;
25098 item=item;
25099
25100 return true;
25101 }
25102
25103 bool has_item(int32_t item_type, int32_t it)
25104 {
25105 //these are here to bypass compiler warnings about unused arguments
25106 item_type=item_type;
25107 it=it;
25108
25109 return true;
25110 }
25111
25112 int32_t get_bmaps(int32_t si)
25113 {
25114 //these are here to bypass compiler warnings about unused arguments
25115 si=si;
25116
25117 return 255;
25118 }
25119
25120 bool no_subscreen()
25121 {
25122 return false;
25123 }
25124
25125 9 static void allocate_crap()
25126 {
25127 9 filepath=(char*)malloc(2048);
25128 9 datapath=(char*)malloc(2048);
25129 9 midipath=(char*)malloc(2048);
25130 9 imagepath=(char*)malloc(2048);
25131 9 tmusicpath=(char*)malloc(2048);
25132 9 last_timed_save=(char*)malloc(2048);
25133
25134
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!filepath || !datapath || !imagepath || !midipath || !tmusicpath || !last_timed_save)
25135 {
25136 Z_error_fatal("Error: no memory for file paths!");
25137 }
25138
25139
25140 9 customtunes = (zctune*)malloc(sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
25141 9 memset(customtunes, 0, sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
25142
25143
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; ++i)
25144 {
25145 2304 customtunes[i].data=NULL;
25146 2304 }
25147
25148
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 9 times.
2277 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
25149 {
25150 2268 midi_string[i+4]=customtunes[i].title;
25151 2268 screen_midi_string[i+5]=customtunes[i].title;
25152 2268 }
25153
25154
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WAV_COUNT; i++)
25155 {
25156
1/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2304 if(sfx_string[i]!=NULL) delete sfx_string[i];
25157 2304 customsfxdata[i].data=NULL;
25158 2304 sfx_string[i] = new char[36];
25159 2304 memset(sfx_string[i], 0, 36);
25160 2304 }
25161
25162
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXWPNS; i++)
25163 {
25164
1/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2304 if(weapon_string[i]!=NULL) delete weapon_string[i];
25165 2304 weapon_string[i] = new char[64];
25166 2304 memset(weapon_string[i], 0, 64);
25167 2304 }
25168
25169
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
25170 {
25171
1/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2304 if(item_string[i]!=NULL) delete item_string[i];
25172 2304 item_string[i] = new char[64];
25173 2304 memset(item_string[i], 0, 64);
25174 2304 }
25175
25176
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
25177 {
25178
1/4
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4608 if(guy_string[i]!=NULL) delete guy_string[i];
25179 4608 guy_string[i] = new char[64];
25180 4608 memset(guy_string[i], 0, 64);
25181 4608 }
25182
25183
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
25184 {
25185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
4608 delete ffscripts[i];
25186
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 ffscripts[i] = new script_data(ScriptType::FFC, i);
25187 4608 }
25188
25189
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
25190 {
25191
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete itemscripts[i];
25192
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 itemscripts[i] = new script_data(ScriptType::Item, i);
25193 2304 }
25194
25195
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
25196 {
25197
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete guyscripts[i];
25198
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 guyscripts[i] = new script_data(ScriptType::NPC, i);
25199 2304 }
25200
25201
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25202 {
25203
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete screenscripts[i];
25204
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 screenscripts[i] = new script_data(ScriptType::Screen, i);
25205 2304 }
25206
25207
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 9 times.
81 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
25208 {
25209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 delete globalscripts[i];
25210
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 globalscripts[i] = new script_data(ScriptType::Global, i);
25211 72 }
25212
25213
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 9 times.
54 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
25214 {
25215
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 delete playerscripts[i];
25216
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 playerscripts[i] = new script_data(ScriptType::Player, i);
25217 45 }
25218
25219
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25220 {
25221
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete lwpnscripts[i];
25222
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
25223 2304 }
25224
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25225 {
25226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 delete ewpnscripts[i];
25227
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
25228 2304 }
25229
25230
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25231 {
25232
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete dmapscripts[i];
25233
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 dmapscripts[i] = new script_data(ScriptType::DMap, i);
25234 2304 }
25235
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25236 {
25237
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete itemspritescripts[i];
25238
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
25239 2304 }
25240
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25241 {
25242
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 delete comboscripts[i];
25243
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 comboscripts[i] = new script_data(ScriptType::Combo, i);
25244 4608 }
25245
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
25246 {
25247
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 delete genericscripts[i];
25248
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 genericscripts[i] = new script_data(ScriptType::Generic, i);
25249 4608 }
25250
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25251 {
25252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 delete subscreenscripts[i];
25253
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
25254 2304 }
25255 9 }
25256
25257 // Removes the top layer encoding from a quest file. See open_quest_file.
25258 // This has zero impact on the contents of the quest file. There should be no way for this to
25259 // break anything.
25260 static void do_unencrypt_qst_command(const char* input_filename, const char* output_filename)
25261 {
25262 // If the file is already an unencrypted packfile, there's nothing to do.
25263 PACKFILE* pf_check = pack_fopen_password(input_filename, F_READ_PACKED, "");
25264 pack_fclose(pf_check);
25265 if (pf_check) return;
25266
25267 int32_t error;
25268 PACKFILE* pf = open_quest_file(&error, input_filename, false);
25269 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE_PACKED, "");
25270 int c;
25271 while ((c = pack_getc(pf)) != EOF)
25272 {
25273 pack_putc(c, pf2);
25274 }
25275 pack_fclose(pf);
25276 pack_fclose(pf2);
25277 clear_quest_tmpfile();
25278 }
25279
25280 // This will remove the PACKFILE compression. Incidentally, it also removes the top encoding layer.
25281 static void do_uncompress_qst_command(const char* input_filename, const char* output_filename)
25282 {
25283 auto unencrypted_result = try_open_maybe_legacy_encoded_file(input_filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
25284 if (unencrypted_result.not_found)
25285 {
25286 printf("qst not found\n");
25287 zq_exit(1);
25288 }
25289 if (!unencrypted_result.compressed && !unencrypted_result.encrypted)
25290 {
25291 // If the file is already an uncompressed file, there's nothing to do but copy it.
25292 fs::copy(input_filename, output_filename);
25293 return;
25294 }
25295
25296 pack_fclose(unencrypted_result.decoded_pf);
25297
25298 int32_t error;
25299 PACKFILE* pf = open_quest_file(&error, input_filename, false);
25300 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE, "");
25301 int c;
25302 while ((c = pack_getc(pf)) != EOF)
25303 {
25304 pack_putc(c, pf2);
25305 }
25306 pack_fclose(pf);
25307 pack_fclose(pf2);
25308 clear_quest_tmpfile();
25309 }
25310
25311 // Copy a quest file by loading and resaving, exactly like if the user did it in the UI.
25312 // Note there could be changes introduced in the loading or saving functions. These are
25313 // typically for compatability, but could possibly be a source of bugs.
25314 2 static void do_copy_qst_command(const char* input_filename, const char* output_filename)
25315 {
25316 2 set_headless_mode();
25317
25318 // We need to init some stuff before loading a quest file will work.
25319 2 int fake_errno = 0;
25320 2 allegro_errno = &fake_errno;
25321 2 get_qst_buffers();
25322
25323 2 int ret = load_quest(input_filename, false);
25324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ret)
25325 {
25326 zq_exit(ret);
25327 }
25328
25329 2 ret = save_quest(output_filename, false);
25330 2 zq_exit(ret);
25331 2 }
25332
25333 int32_t Awpn=-1, Bwpn=-1, Xwpn = -1, Ywpn = -1;
25334 63 sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations, portals;
25335 int32_t exittimer = 10000, exittimer2 = 100;
25336
25337 1 static bool partial_load_test(const char* test_dir)
25338 {
25339 1 int ret = load_quest("quests/Z1 Recreations/classic_1st.qst", false);
25340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
25341 {
25342 printf("failed to load classic_1st.qst: ret == %d\n", ret);
25343 return false;
25344 }
25345
25346 1 int cont = DMaps[0].cont;
25347
25348 // Skip same stuff as used in zq_tiles.cpp for grabbing tiles from a qst.
25349 byte skip_flags[4];
25350
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
27 for (int i=0; i<skip_max; ++i)
25351 26 set_bit(skip_flags,i,1);
25352 1 set_bit(skip_flags,skip_tiles,0);
25353 1 set_bit(skip_flags,skip_header,0);
25354 zquestheader tempheader;
25355 1 memset(&tempheader, 0, sizeof(zquestheader));
25356
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto ptux_path = fs::path(test_dir) / "quests/PTUX.qst";
25357
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 ret = loadquest(ptux_path.string().c_str(), &tempheader, &QMisc, customtunes, false, skip_flags);
25358
25359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
25360 {
25361 printf("failed to load PTUX.qst: ret == %d\n", ret);
25362 return false;
25363 }
25364
25365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (DMaps[0].cont != cont)
25366 {
25367 printf("unexpected modification: DMaps[0].cont == %d, should be %d\n", DMaps[0].cont, cont);
25368 return false;
25369 }
25370
25371 // TODO should run replay. Currently, resaving classic_1st.qst fails its replay (see test_save in test_zeditor.py)
25372
25373 1 return true;
25374 1 }
25375
25376 template <typename ...Params>
25377 [[noreturn]] void FatalConsole(const char *format, Params&&... params)
25378 {
25379 FFCore.ZScriptConsole(CConsoleLoggerEx::COLOR_RED|CConsoleLoggerEx::COLOR_INTENSITY|CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"");
25380 Z_error_fatal(format, std::forward<Params>(params)...);
25381 }
25382
25383 static bool application_has_loaded;
25384
25385 6 int32_t main(int32_t argc,char **argv)
25386 {
25387 6 int test_zc_arg = used_switch(argc, argv, "-test-zc");
25388
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (test_zc_arg > 0)
25389 1 set_headless_mode();
25390
25391 6 zalleg_setup_allegro(App::zquest, argc, argv);
25392 6 allocate_crap();
25393
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_should_zprint_cb([]() {
25394 return get_qr(qr_SCRIPTERRLOG) || DEVLEVEL > 0;
25395 });
25396
25397 6 int package_arg = used_switch(argc, argv, "-package");
25398
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (package_arg > 0)
25399 {
25400 if (package_arg + 3 > argc)
25401 {
25402 printf("%d\n", argc);
25403 printf("expected -package <game.qst> <package name>\n");
25404 zq_exit(1);
25405 }
25406
25407 const char* input_filename = argv[package_arg + 1];
25408 const char* package_name = argv[package_arg + 2];
25409 if (auto error = package_create(input_filename, package_name))
25410 Z_error_fatal("%s\n", error->c_str());
25411 zq_exit(0);
25412 }
25413
25414 6 int copy_qst_arg = used_switch(argc, argv, "-copy-qst");
25415
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (copy_qst_arg > 0)
25416 {
25417
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (copy_qst_arg + 3 > argc)
25418 {
25419 printf("%d\n", argc);
25420 printf("expected -copy-qst <input> <output>\n");
25421 zq_exit(1);
25422 }
25423
25424 2 const char* input_filename = argv[copy_qst_arg + 1];
25425 2 const char* output_filename = argv[copy_qst_arg + 2];
25426 2 do_copy_qst_command(input_filename, output_filename);
25427 2 }
25428
25429 6 Z_title("%s, %s",ZQ_EDITOR_NAME, getVersionString());
25430
25431
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!get_qst_buffers())
25432 {
25433 Z_error_fatal("Error");
25434 }
25435
25436 6 undocombobuf.clear();
25437 6 undocombobuf.resize(MAXCOMBOS);
25438
25439
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
25440 {
25441 Z_error_fatal("Error: no memory for tile undo buffer!");
25442 }
25443
25444 6 memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
25445
25446 6 Z_message("Resetting new tile buffer...");
25447 6 newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
25448
25449
2/2
✓ Branch 0 taken 1501500 times.
✓ Branch 1 taken 6 times.
1501506 for(int32_t j=0; j<NEWMAXTILES; j++)
25450 1501500 newtilebuf[j].data=NULL;
25451
25452 6 Z_message("OK\n");
25453
25454 6 zc_srand(time(0));
25455
25456
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (test_zc_arg > 0)
25457 {
25458 1 set_headless_mode();
25459
25460
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (test_zc_arg + 1 > argc)
25461 {
25462 printf("%d\n", argc);
25463 printf("expected -test-zc <path to test dir>\n");
25464 zq_exit(1);
25465 }
25466
25467 1 const char* test_dir = argv[test_zc_arg + 1];
25468
25469 // We need to init some stuff before loading a quest file will work.
25470 1 int fake_errno = 0;
25471 1 allegro_errno = &fake_errno;
25472 1 get_qst_buffers();
25473
25474 1 bool success = true;
25475
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!partial_load_test(test_dir))
25476 {
25477 success = false;
25478 printf("partial_load_test failed\n");
25479 }
25480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (success)
25481 1 printf("all tests passed\n");
25482 1 zq_exit(success ? 0 : 1);
25483 1 }
25484
25485 6 int unencrypt_qst_arg = used_switch(argc, argv, "-unencrypt-qst");
25486
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (unencrypt_qst_arg > 0)
25487 {
25488 if (unencrypt_qst_arg + 3 > argc)
25489 {
25490 printf("%d\n", argc);
25491 printf("expected -unencrypt-qst <input> <output>\n");
25492 zq_exit(1);
25493 }
25494
25495 const char* input_filename = argv[unencrypt_qst_arg + 1];
25496 const char* output_filename = argv[unencrypt_qst_arg + 2];
25497 do_unencrypt_qst_command(input_filename, output_filename);
25498 zq_exit(0);
25499 }
25500
25501 6 int uncompress_qst_arg = used_switch(argc, argv, "-uncompress-qst");
25502
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (uncompress_qst_arg > 0)
25503 {
25504 if (uncompress_qst_arg + 3 > argc)
25505 {
25506 printf("%d\n", argc);
25507 printf("expected -uncompress-qst <input> <output>\n");
25508 zq_exit(1);
25509 }
25510
25511 const char* input_filename = argv[uncompress_qst_arg + 1];
25512 const char* output_filename = argv[uncompress_qst_arg + 2];
25513 do_uncompress_qst_command(input_filename, output_filename);
25514 zq_exit(0);
25515 }
25516
25517 6 three_finger_flag=false;
25518
25519 #ifndef __EMSCRIPTEN__
25520
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(zc_get_config("zquest","open_debug_console",0))
25521 initConsole();
25522 #endif
25523
25524 LOCK_VARIABLE(lastfps);
25525
25526 LOCK_VARIABLE(framecnt);
25527 LOCK_FUNCTION(fps_callback);
25528
25529
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
25530 {
25531 Z_error_fatal("couldn't allocate timer");
25532 }
25533
25534
25535 LOCK_VARIABLE(dclick_status);
25536 LOCK_VARIABLE(dclick_time);
25537 6 lock_dclick_function();
25538 6 install_int(dclick_check, 20);
25539
25540 6 set_gfx_mode(GFX_TEXT,80,50,0,0);
25541
25542 6 Z_message("Loading data files:\n");
25543
25544 6 packfile_password(datapwd);
25545
25546 6 Z_message("ZQuest.Dat...");
25547
25548
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if((zcdata=load_datafile(moduledata.datafiles[zquest_dat]))==NULL)
25549 FatalConsole("failed to load zquest.dat");
25550
25551 6 Z_message("OK\n");
25552
25553 6 packfile_password("");
25554
25555
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 helpstr = util::read_text_file("docs/zquest.txt");
25556
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 zstringshelpstr = util::read_text_file("docs/zstrings.txt");
25557
25558 // loading data files...
25559
25560 6 filepath[0]=temppath[0]=0;
25561
25562 6 const char *default_path="";
25563
25564 6 strcpy(datapath,zc_get_config("zquest",data_path_name,default_path));
25565 6 strcpy(midipath,zc_get_config("zquest",midi_path_name,default_path));
25566 6 strcpy(imagepath,zc_get_config("zquest",image_path_name,default_path));
25567 6 strcpy(tmusicpath,zc_get_config("zquest",tmusic_path_name,default_path));
25568 6 chop_path(datapath);
25569 6 chop_path(midipath);
25570 6 chop_path(imagepath);
25571 6 chop_path(tmusicpath);
25572
25573 6 DisableLPalShortcuts = zc_get_config("zquest","dis_lpal_shortcut",1);
25574 6 DisableCompileConsole = zc_get_config("zquest","internal_compile_console",0);
25575 6 MouseScroll = zc_get_config("zquest","mouse_scroll",0);
25576 6 WarnOnInitChanged = zc_get_config("zquest","warn_initscript_changes",1);
25577 6 MMapCursorStyle = zc_get_config("zquest","cursorblink_style",1);
25578 6 LayerDitherBG = zc_get_config("zquest", "layer_dither_bg", -1);
25579 6 LayerDitherSz = zc_get_config("zquest", "layer_dither_sz", 3);
25580 6 InvalidBG = zc_get_config("zquest", "invalid_bg", 0);
25581 6 TileProtection = zc_get_config("zquest","tile_protection",1);
25582 6 ComboProtection = zc_get_config("zquest","combo_protection",TileProtection);
25583 6 ShowGrid = zc_get_config("zquest","show_grid",0);
25584 6 GridColor = zc_get_config("zquest","grid_color",15);
25585 6 CmbCursorCol = zc_get_config("zquest","combo_cursor_color",15);
25586 6 TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
25587 6 CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
25588 6 TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
25589 6 CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
25590 6 CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
25591 6 SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
25592 6 SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
25593 6 SavePaths = zc_get_config("zquest","save_paths",1);
25594 6 CycleOn = zc_get_config("zquest","cycle_on",1);
25595 6 ShowFPS = zc_get_config("zquest","showfps",0)!=0;
25596 6 SaveDragResize = zc_get_config("zquest","save_drag_resize",0)!=0;
25597 6 DragAspect = zc_get_config("zquest","drag_aspect",0)!=0;
25598 6 SaveWinPos = zc_get_config("zquest","save_window_position",0)!=0;
25599 6 ComboBrush = zc_get_config("zquest","combo_brush",0);
25600 6 FloatBrush = zc_get_config("zquest","float_brush",0);
25601 6 AutoBrush = zc_get_config("zquest","autobrush",1);
25602 6 LinkedScroll = zc_get_config("zquest","linked_comboscroll",0);
25603 6 allowHideMouse = zc_get_config("ZQ_GUI","allowHideMouse",0);
25604 6 ShowFavoriteComboModes = zc_get_config("ZQ_GUI","show_fav_combo_modes",1);
25605 6 NoHighlightLayer0 = zc_get_config("zquest","no_highlight_layer0",0);
25606 6 RulesetDialog = zc_get_config("zquest","rulesetdialog",1);
25607 6 EnableTooltips = zc_get_config("zquest","enable_tooltips",1);
25608 6 TooltipsHighlight = zc_get_config("zquest","ttip_highlight",1);
25609 6 tooltip_maxtimer = vbound(zc_get_config("zquest","ttip_timer",30),0,60*60);
25610 6 ShowFFScripts = zc_get_config("zquest","showffscripts",1);
25611 6 ShowSquares = zc_get_config("zquest","showsquares",1);
25612 6 ShowFFCs = zc_get_config("zquest","showffcs",0);
25613 6 ShowInfo = zc_get_config("zquest","showinfo",1);
25614 6 skipLayerWarning = zc_get_config("zquest","skip_layer_warning",0);
25615 6 numericalFlags = zc_get_config("zquest","numerical_flags",0);
25616 6 ViewLayer2BG = zc_get_config("zquest","layer2_bg",0);
25617 6 ViewLayer3BG = zc_get_config("zquest","layer3_bg",0);
25618 6 ActiveLayerHighlight = zc_get_config("zquest","hl_active_lyr",0);
25619
25620 6 OpenLastQuest = zc_get_config("zquest","open_last_quest",0);
25621 6 ShowMisalignments = zc_get_config("zquest","show_misalignments",0);
25622 6 AnimationOn = zc_get_config("zquest","animation_on",1);
25623 6 AutoBackupRetention = zc_get_config("zquest","auto_backup_retention",2);
25624 6 AutoSaveInterval = zc_get_config("zquest","auto_save_interval",6);
25625 6 AutoSaveRetention = zc_get_config("zquest","auto_save_retention",2);
25626 6 UncompressedAutoSaves = zc_get_config("zquest","uncompressed_auto_saves",1);
25627 6 OverwriteProtection = zc_get_config("zquest","overwrite_prevention",0)!=0;
25628 6 ImportMapBias = zc_get_config("zquest","import_map_bias",0);
25629
25630 6 KeyboardRepeatDelay = zc_get_config("zquest","keyboard_repeat_delay",300);
25631 6 KeyboardRepeatRate = zc_get_config("zquest","keyboard_repeat_rate",80);
25632
25633 // Frameskip = zc_get_config("zquest","frameskip",0); //todo: this is not actually supported yet.
25634 6 RequestedFPS = zc_get_config("zquest","fps",60);
25635
25636 // Autofill for Combo Page, Tile Page
25637 6 PreFillTileEditorPage = zc_get_config("zquest","PreFillTileEditorPage",0);
25638 6 PreFillComboEditorPage = zc_get_config("zquest","PreFillComboEditorPage",0);
25639
25640 6 pixeldb = zc_get_config("ZQ_GUI","bottom_8_pixels",0);
25641 6 infobg = zc_get_config("ZQ_GUI","info_text_bg",0);
25642
25643 6 large_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_large",0);
25644 6 compact_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_compact",1);
25645
25646 6 compact_square_panels = zc_get_config("ZQ_GUI","square_panels_compact",0);
25647
25648 6 large_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_large",0);
25649 6 compact_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_compact",1);
25650 6 large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
25651 6 compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);
25652
25653
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(zc_get_config("gui","disable_window_resizing",0))
25654 all_set_resize_flag(false);
25655
25656 6 load_hotkeys();
25657
25658 #ifdef _WIN32
25659 zqUseWin32Proc = zc_get_config("zquest","zq_win_proc_fix",0);
25660
25661 #endif
25662
25663
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!render_timer_start())
25664 {
25665 Z_error_fatal("couldn't allocate timer");
25666 }
25667
25668 6 byte layermask = zc_get_config("zquest","layer_mask",0x7F);
25669 6 int32_t usefullscreen = zc_get_config("zquest","fullscreen",0);
25670 6 tempmode = (usefullscreen == 0 ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN);
25671
25672
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 6 times.
48 for(int32_t x=0; x<7; x++)
25673 {
25674 42 LayerMaskInt[x]=get_bit(&layermask,x);
25675 42 }
25676
25677 6 DuplicateAction[0] = zc_get_config("zquest","normal_duplicate_action",2);
25678 6 DuplicateAction[1] = zc_get_config("zquest","horizontal_duplicate_action",0);
25679 6 DuplicateAction[2] = zc_get_config("zquest","vertical_duplicate_action",0);
25680 6 DuplicateAction[3] = zc_get_config("zquest","both_duplicate_action",0);
25681 6 LeechUpdate = zc_get_config("zquest","leech_update",500);
25682 6 LeechUpdateTiles = zc_get_config("zquest","leech_update_tiles",1);
25683 6 OnlyCheckNewTilesForDuplicates = zc_get_config("zquest","only_check_new_tiles_for_duplicates",0);
25684 //gui_colorset = zc_get_config("zquest","gui_colorset",0);
25685
25686 6 strcpy(last_timed_save,zc_get_config("zquest","last_timed_save",""));
25687
25688 6 midi_volume = zc_get_config("zquest", "midi", 255);
25689
25690 6 abc_patternmatch = zc_get_config("zquest", "lister_pattern_matching", 1);
25691 6 NoScreenPreview = zc_get_config("zquest", "no_preview", 0);
25692
25693 6 monochrome_console = zc_get_config("CONSOLE","monochrome_debuggers",0)?1:0;
25694
25695 6 try_recovering_missing_scripts = 0;//zc_get_config("Compiler", "try_recovering_missing_scripts",0);
25696 //We need to remove all of the zeldadx refs to the config file for zquest.
25697
25698 6 set_keyboard_rate(KeyboardRepeatDelay,KeyboardRepeatRate);
25699
25700 6 is_compact = zc_get_config("ZQ_GUI","compact_mode",1);
25701 6 mapscreenbmp = nullptr;
25702 6 brushbmp = nullptr;
25703 6 brushscreen = nullptr;
25704 6 screen2 = nullptr;
25705 6 tmp_scr = nullptr;
25706 6 menu1 = nullptr;
25707 6 menu3 = nullptr;
25708
25709
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 6 times.
7566 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
25710 {
25711 7560 favorite_combos[i]=-1;
25712 7560 pool_combos[i].clear();
25713 7560 }
25714 6 FavoriteComboPage = 0;
25715 6 pool_dirty = true;
25716
25717
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(used_switch(argc,argv,"-d"))
25718 {
25719 set_debug(!strcmp(zquestpwd,zc_get_config("zquest","debug_this","")));
25720 }
25721
25722 6 zcmusic_init();
25723 6 zcmixer = zcmixer_create();
25724 2783 install_int_ex([](){ zcmusic_poll(); }, MSEC_TO_TIMER(25));
25725
25726 6 set_color_depth(8);
25727
25728 6 set_close_button_callback((void (*)()) hit_close_button);
25729
25730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(used_switch(argc,argv,"-fullscreen"))
25731 {
25732 tempmode = GFX_AUTODETECT_FULLSCREEN;
25733 }
25734
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(used_switch(argc,argv,"-windowed"))
25735 {
25736 tempmode=GFX_AUTODETECT_WINDOWED;
25737 }
25738
25739 6 zq_screen_w = LARGE_W;
25740 6 zq_screen_h = LARGE_H;
25741 6 window_width = zc_get_config("zquest","window_width",-1);
25742 6 window_height = zc_get_config("zquest","window_height",-1);
25743 6 auto [w, h] = zc_get_default_display_size(LARGE_W, LARGE_H, window_width, window_height);
25744
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 int32_t videofail = is_headless() ? 0 : (set_gfx_mode(tempmode,w,h,zq_screen_w,zq_screen_h));
25745
25746 //extra block here is intentional
25747
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(videofail!=0)
25748 {
25749 quit_game();
25750 allegro_exit();
25751 }
25752
25753 6 zalleg_create_window();
25754 6 Z_message("gfx mode set at -%d %dbpp %d x %d \n",
25755 6 tempmode, get_color_depth(), zq_screen_w, zq_screen_h);
25756
25757 6 set_window_title("ZC Editor");
25758
25759 6 load_size_poses();
25760
25761
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!is_headless())
25762 {
25763 // Just in case.
25764 while (!all_get_display()) {
25765 al_rest(1);
25766 }
25767
25768 al_resize_display(all_get_display(), w, h);
25769 }
25770
25771
25772 #ifndef __EMSCRIPTEN__
25773
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if (!all_get_fullscreen_flag() && !is_headless()) {
25774 al_resize_display(all_get_display(), w, h);
25775
25776 int window_w = al_get_display_width(all_get_display());
25777 int window_h = al_get_display_height(all_get_display());
25778
25779 int new_x = zc_get_config("zquest","window_x",0);
25780 int new_y = zc_get_config("zquest","window_y",0);
25781 if(zc_get_config("zquest","save_window_position",0) && (new_x || new_y))
25782 {
25783 //load saved position
25784 //already stored in new_x/new_y
25785 }
25786 else
25787 {
25788 //Get default position
25789 ALLEGRO_MONITOR_INFO info;
25790 al_get_monitor_info(0, &info);
25791
25792 int mw = (info.x2 - info.x1);
25793 int mh = (info.y2 - info.y1);
25794 new_x = mw / 2 - window_w / 2;
25795 new_y = mh / 2 - window_h / 2;
25796 //Don't spawn the window too far down (taskbar?)
25797 if(new_y + window_h > mh - 72)
25798 new_y = mh-72-window_h;
25799 }
25800 #ifdef ALLEGRO_MACOSX
25801 if (zc_get_config("zquest","save_window_position",0))
25802 al_set_window_position(all_get_display(), new_x, new_y);
25803 #else
25804 al_set_window_position(all_get_display(), new_x, new_y);
25805 #endif
25806 }
25807 #endif
25808
25809 6 position_mouse(zq_screen_w/2,zq_screen_h/2);
25810
25811 6 dmapbmp_small = create_bitmap_ex(8,65,33);
25812 6 dmapbmp_large = create_bitmap_ex(8,177,81);
25813
25814
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!screen2 || !tmp_scr || !menu1 || !menu3 || !dmapbmp_large || !dmapbmp_large || !brushbmp || !brushscreen)// || !brushshadowbmp )
25815 {
25816 Z_error_fatal("Failed to create system bitmaps!\n");
25817 return 1;
25818 }
25819
25820 6 int quick_assign_arg = used_switch(argc, argv, "-quick-assign");
25821
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (quick_assign_arg > 0)
25822 {
25823 4 is_zq_replay_test = true;
25824 4 set_headless_mode();
25825
25826 4 int load_ret = load_quest(argv[quick_assign_arg + 1], false);
25827 4 bool success = load_ret == qe_OK;
25828
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!success)
25829 {
25830 printf("Failed to load quest: %d\n", load_ret);
25831 zq_exit(1);
25832 }
25833
25834 4 success = do_compile_and_slots(1, false);
25835
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!success)
25836 {
25837 printf("Failed to compile\n");
25838 zq_exit(1);
25839 }
25840
25841 4 success = save_quest(argv[quick_assign_arg + 1], false) == 0;
25842
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!success)
25843 {
25844 printf("Failed to save quest\n");
25845 zq_exit(1);
25846 }
25847
25848 4 zq_exit(0);
25849 4 }
25850
25851 6 int export_strings_arg = used_switch(argc, argv, "-export-strings");
25852
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (export_strings_arg > 0)
25853 {
25854
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (export_strings_arg + 3 > argc)
25855 {
25856 printf("%d\n", argc);
25857 printf("expected -export-strings input.qst output.tsv\n");
25858 zq_exit(1);
25859 }
25860
25861 1 is_zq_replay_test = true;
25862 1 set_headless_mode();
25863
25864 1 int load_ret = load_quest(argv[export_strings_arg + 1], false);
25865 1 bool success = load_ret == qe_OK;
25866
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
25867 {
25868 printf("Failed to load quest: %d\n", load_ret);
25869 zq_exit(1);
25870 }
25871
25872 1 success = save_strings_tsv(argv[export_strings_arg + 2]);
25873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
25874 {
25875 printf("Failed to export strings\n");
25876 zq_exit(1);
25877 }
25878
25879 1 zq_exit(0);
25880 1 }
25881
25882
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!is_headless())
25883 {
25884 RGB* zquest_pal = (RGB*)zcdata[PAL_ZQUEST].dat;
25885 for (int i = 0; i < 256; i++)
25886 {
25887 zquest_pal[i].r = _rgb_scale_6[zquest_pal[i].r];
25888 zquest_pal[i].g = _rgb_scale_6[zquest_pal[i].g];
25889 zquest_pal[i].b = _rgb_scale_6[zquest_pal[i].b];
25890 }
25891
25892 zc_set_palette(zquest_pal);
25893 get_palette(RAMpal);
25894 load_colorset(gui_colorset);
25895 zc_set_palette(RAMpal);
25896 clear_to_color(screen,vc(0));
25897 }
25898
25899 6 zScript = string();
25900 6 strcpy(zScriptBytes, "0 Bytes in Buffer");
25901
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 for(int32_t i=0; i<MOUSE_BMP_MAX; i++)
25902 {
25903
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<4; j++)
25904 {
25905 48 mouse_bmp[i][j] = NULL;
25906 48 mouse_bmp_1x[i][j] = NULL;
25907 48 }
25908 12 }
25909 6 load_mice();
25910 6 gui_mouse_focus=0;
25911 6 MouseSprite::set(ZQM_NORMAL);
25912 6 render_zq(); // Ensure the rendering bitmaps are setup.
25913
25914 #ifdef __EMSCRIPTEN__
25915 em_mark_ready_status();
25916 #endif
25917
25918 6 load_icons();
25919
25920 6 bool load_last_timed_save=false;
25921
25922 6 load_recent_quests();
25923 6 refresh_recent_menu();
25924 //clearConsole();
25925
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if((last_timed_save[0]!=0)&&(exists(last_timed_save)))
25926 {
25927 if(jwin_alert("ZQuest","It appears that ZQuest crashed last time.","Would you like to load the last timed save?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
25928 {
25929 int32_t ret = load_quest(last_timed_save);
25930
25931 if(ret == qe_OK)
25932 {
25933 strcpy(filepath,last_timed_save);
25934 load_last_timed_save=true;
25935 saved=false;
25936 }
25937 else
25938 {
25939 jwin_alert("Error","Unable to reload the last timed save.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
25940 }
25941 }
25942 }
25943
25944
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if(!load_last_timed_save)
25945 {
25946 1 strcpy(filepath,zc_get_config("zquest",last_quest_name,""));
25947
25948
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(argc>1 && argv[1][0]!='-')
25949 {
25950 int32_t ret = load_quest(argv[1]);
25951
25952 if(ret == qe_OK)
25953 {
25954 first_save=true;
25955 strcpy(filepath,argv[1]);
25956 refresh(rALL);
25957 }
25958 }
25959
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 else if(OpenLastQuest&&filepath[0]&&exists(filepath)&&!used_switch(argc,argv,"-new"))
25960 {
25961 int32_t ret = load_quest(filepath);
25962
25963 if(ret == qe_OK)
25964 {
25965 first_save=true;
25966 refresh(rALL);
25967 }
25968 else
25969 {
25970 filepath[0]=temppath[0]=0;
25971 first_save=false;
25972 }
25973 }
25974 else
25975 {
25976 1 init_quest();
25977
25978
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(RulesetDialog)
25979 {
25980 PickRuleset();
25981 PickRuleTemplate();
25982 }
25983
25984 //otherwise the blank quest gets the name of the last loaded quest... not good! -DD
25985 1 filepath[0]=temppath[0]=0;
25986 1 first_save=false;
25987 }
25988 1 }
25989
25990
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if(used_switch(argc,argv,"-q"))
25991 {
25992 1 Z_message("-q switch used, quitting program.\n");
25993 1 zq_exit(0);
25994 1 }
25995
25996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 for(int32_t x=0; x<MAXITEMS; x++)
25997 {
25998 lens_hint_item[x][0]=0;
25999 lens_hint_item[x][1]=0;
26000 }
26001
26002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 for(int32_t x=0; x<MAXWPNS; x++)
26003 {
26004 lens_hint_weapon[x][0]=0;
26005 lens_hint_weapon[x][1]=0;
26006 }
26007
26008 6 load_selections();
26009 6 load_arrows();
26010 6 clear_to_color(menu1,vc(0));
26011 6 DIALOG_PLAYER *player2=init_dialog(dialogs,-1);
26012
26013 6 get_palette(RAMpal);
26014
26015 6 rgb_map = &zq_rgb_table;
26016
26017 #ifdef __EMSCRIPTEN__
26018 {
26019 int qs_map = EM_ASM_INT({
26020 return new URL(location.href).searchParams.get('map') ?? -1;
26021 });
26022 int qs_screen = EM_ASM_INT({
26023 return new URL(location.href).searchParams.get('screen') ?? -1;
26024 });
26025 if (qs_map != -1 && qs_screen != -1) {
26026 Map.setCurrMap(qs_map);
26027 Map.setCurrScr(qs_screen);
26028 }
26029 }
26030 #endif
26031
26032 // setup_combo_animations();
26033 6 pause_refresh = false;
26034 6 refresh_pal();
26035 6 refresh(rALL);
26036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 for(int q = 0; q < brush_width_menu.size(); ++q)
26037 brush_width_menu.at(q)->select(q==0);
26038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 for(int q = 0; q < brush_height_menu.size(); ++q)
26039 brush_height_menu.at(q)->select(q==0);
26040 6 set_filltype(1);
26041
26042 6 rebuild_trans_table();
26043
26044
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!is_headless())
26045 {
26046 set_display_switch_mode(SWITCH_BACKGROUND);
26047 set_display_switch_callback(SWITCH_OUT, switch_out);
26048 set_display_switch_callback(SWITCH_IN, switch_in);
26049 }
26050
26051
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!update_dialog(player2))
26052 exiting_program = true;
26053 //clear_keybuf();
26054 6 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
26055 6 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
26056
26057 6 fix_drawing_mode_menu();
26058
26059
26060 #ifdef _WIN32
26061
26062 if(zqUseWin32Proc != FALSE)
26063 {
26064 al_trace("Config file warning: \"zq_win_proc_fix\" enabled switch found. This can cause crashes on some computers.\n");
26065 win32data.zqSetDefaultThreadPriority(0);
26066 win32data.zqSetCustomCallbackProc(al_get_win_window_handle(all_get_display()));
26067 }
26068
26069 #endif
26070
26071 6 time(&auto_save_time_start);
26072
26073 6 FFCore.init();
26074 6 ZQincludePaths = FFCore.includePaths;
26075
26076 6 Map.setCopyFFC(-1); //Do not have an initial ffc on the clipboard.
26077 6 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
26078 6 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
26079 6 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
26080 6 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
26081 6 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
26082
26083 6 init_ffpos();
26084
26085 6 call_foo_dlg();
26086
26087 6 application_has_loaded = true;
26088
26089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 while(!exiting_program)
26090 {
26091 #ifdef _WIN32
26092 if(zqUseWin32Proc != FALSE)
26093 win32data.Update(Frameskip); //experimental win32 fixes
26094 #endif
26095 check_autosave();
26096 ++alignment_arrow_timer;
26097
26098 if(alignment_arrow_timer>63)
26099 {
26100 alignment_arrow_timer=0;
26101 }
26102
26103 file_menu.disable_uid(MENUID_FILE_SAVE, saved||disable_saving||OverwriteProtection);
26104 file_menu.disable_uid(MENUID_FILE_REVERT, saved||disable_saving||OverwriteProtection);
26105 file_menu.disable_uid(MENUID_FILE_SAVEAS, disable_saving);
26106
26107 fixtools_menu.disable_uid(MENUID_FIXTOOL_OLDSTRING,
26108 !(get_qr(qr_OLD_STRING_EDITOR_MARGINS)
26109 ||get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)));
26110
26111 edit_menu.disable_uid(MENUID_EDIT_UNDO, !Map.CanUndo());
26112 edit_menu.disable_uid(MENUID_EDIT_REDO, !Map.CanRedo());
26113
26114 bool canpaste = Map.CanPaste();
26115 edit_menu.disable_uid(MENUID_EDIT_PASTE, !canpaste);
26116 edit_menu.disable_uid(MENUID_EDIT_PASTEALL, !canpaste);
26117 edit_menu.disable_uid(MENUID_EDIT_ADVPASTE, !canpaste);
26118 edit_menu.disable_uid(MENUID_EDIT_SPECPASTE, !canpaste);
26119 rc_menu_screen.disable_uid(MENUID_RCSCREEN_PASTE, !canpaste);
26120 rc_menu_screen.disable_uid(MENUID_RCSCREEN_ADVPASTE, !canpaste);
26121 rc_menu_screen.disable_uid(MENUID_RCSCREEN_SPECPASTE, !canpaste);
26122 for(MenuItem& mit : paste_menu.inner())
26123 mit.disable(!canpaste);
26124 for(MenuItem& mit : paste_item_menu.inner())
26125 mit.disable(!canpaste);
26126
26127 edit_menu.disable_uid(MENUID_EDIT_COPY, !(Map.CurrScr()->valid&mVALID));
26128 edit_menu.disable_uid(MENUID_EDIT_DELETE, !(Map.CurrScr()->valid&mVALID));
26129
26130 // Are some things selected?
26131 view_menu.select_uid(MENUID_VIEW_WALKABILITY, Flags&cWALK);
26132 view_menu.select_uid(MENUID_VIEW_FLAGS, Flags&cFLAGS);
26133 view_menu.select_uid(MENUID_VIEW_CSET, Flags&cCSET);
26134 view_menu.select_uid(MENUID_VIEW_TYPES, Flags&cCTYPE);
26135 view_menu.select_uid(MENUID_VIEW_INFO, ShowInfo);
26136 view_menu.select_uid(MENUID_VIEW_SQUARES, ShowSquares);
26137 view_menu.select_uid(MENUID_VIEW_FFCS, ShowFFCs);
26138 view_menu.select_uid(MENUID_VIEW_SCRIPTNAMES, ShowFFScripts);
26139 view_menu.select_uid(MENUID_VIEW_GRID, ShowGrid);
26140 view_menu.select_uid(MENUID_VIEW_DARKNESS, get_qr(qr_NEW_DARKROOM) && (Flags&cNEWDARK));
26141 view_menu.select_uid(MENUID_VIEW_L2BG, ViewLayer2BG);
26142 view_menu.select_uid(MENUID_VIEW_L3BG, ViewLayer3BG);
26143 view_menu.select_uid(MENUID_VIEW_LAYERHIGHLIGHT, ActiveLayerHighlight);
26144
26145 maps_menu.disable_uid(MENUID_MAPS_NEXT, !map_count || Map.getCurrMap() >= map_count);
26146 maps_menu.disable_uid(MENUID_MAPS_PREV, Map.getCurrMap()<=0);
26147
26148 etc_menu.disable_uid(MENUID_ETC_VIDMODE, isFullScreen()==1);
26149 etc_menu.select_uid(MENUID_ETC_FULLSCREEN, isFullScreen()==1);
26150
26151 if(!update_dialog(player2))
26152 exiting_program = true;
26153
26154 //clear_keybuf();
26155 handle_close_btn_quit();
26156 }
26157
26158 6 zq_exit(0);
26159 6 return 0;
26160 }
26161 END_OF_MAIN()
26162
26163 9 void zq_exit(int code)
26164 {
26165 9 parser_console.kill();
26166 9 killConsole();
26167
26168 9 quit_game();
26169 9 allegro_exit();
26170 9 exit(code);
26171 }
26172
26173 42 void init_bitmap(BITMAP** bmp, int32_t w, int32_t h)
26174 {
26175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(*bmp)
26176 destroy_bitmap(*bmp);
26177 42 *bmp = create_bitmap_ex(8,w,h);
26178 42 clear_bitmap(*bmp);
26179 42 }
26180 6 void load_size_poses()
26181 {
26182 6 ttip_uninstall_all();
26183
26184 6 FONT* favcmdfont = get_custom_font(CFONT_FAVCMD);
26185 6 FONT* guifont = get_custom_font(CFONT_GUI);
26186
26187 6 d_nbmenu_proc(MSG_START, &dialogs[0], 0);
26188
26189 6 commands_list.xscale = command_buttonwidth;
26190 6 commands_list.yscale = 10+text_height(favcmdfont);
26191
26192 6 auto drawmode_wid = 64;
26193
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
42 for(auto q = 0; q < dm_max; ++q)
26194 {
26195 36 auto wid = text_length(guifont, dm_names[q]);
26196
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(wid > drawmode_wid)
26197 drawmode_wid = wid;
26198 36 }
26199
26200 //Main GUI objects
26201
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(is_compact)
26202 {
26203 6 num_combo_cols = 2;
26204 6 combo_col_scale = 16;
26205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(compact_merged_combopane)
26206 {
26207 6 num_combo_cols = 1;
26208 6 combo_col_scale = 32;
26209 6 }
26210
26211 6 mapscreen_x=0;
26212 6 mapscreen_y=dialogs[0].h;
26213 6 mapscreensize=3;
26214 6 showedges=0;
26215 6 showallpanels=0;
26216
26217 6 blackout_color=8;
26218
26219 6 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreensize);
26220 6 combolist_window.w=zq_screen_w-mapscr_wid;
26221 6 combolist_window.x=zq_screen_w-combolist_window.w;
26222
26223 6 favorites_window.x=combolist_window.x;
26224 6 favorites_window.w=combolist_window.w;
26225 6 favorites_window.h=136;
26226 6 favorites_window.y=zq_screen_h-favorites_window.h;
26227
26228 6 combolist_window.y=0;
26229 6 combolist_window.h=favorites_window.y-combolist_window.y;
26230
26231 6 combo_preview.x=zq_screen_w-32-8;
26232 6 combo_preview.y=combolist_window.y+6;
26233 6 combo_preview.w=32;
26234 6 combo_preview.h=32;
26235 6 combo_preview2.clear();
26236
26237 6 auto col_wid = 4*combo_col_scale;
26238 6 auto cols_wid = col_wid * num_combo_cols;
26239 6 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
26240
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 for(auto q = 0; q < num_combo_cols; ++q)
26241 {
26242 6 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
26243 6 combolist[q].y=combolist_window.y+54;
26244 6 combolist[q].w=4;
26245 6 combolist[q].h=compact_merged_combopane ? 15 : 30;
26246 6 combolist[q].xscale = combo_col_scale;
26247 6 combolist[q].yscale = combo_col_scale;
26248
26249 6 comboaliaslist[q].x = combolist[q].x;
26250 6 comboaliaslist[q].y = combolist[q].y;
26251 6 comboaliaslist[q].w = 4;
26252 6 comboaliaslist[q].h = compact_merged_combopane ? 13 : 26;
26253 6 comboaliaslist[q].xscale = combo_col_scale;
26254 6 comboaliaslist[q].yscale = combo_col_scale;
26255
26256 6 combolistscrollers[q].w=2;
26257 6 combolistscrollers[q].h=1;
26258 6 combolistscrollers[q].xscale=11;
26259 6 combolistscrollers[q].yscale=11;
26260 6 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
26261 6 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-3;
26262 6 }
26263
26264 6 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
26265 6 comboalias_preview.h=64;
26266 6 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
26267 6 comboalias_preview.w=64;
26268
26269 6 combo_merge_btn.w = 20;
26270 6 combo_merge_btn.h = 20;
26271 6 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
26272 6 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
26273
26274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(num_combo_cols == 1)
26275 {
26276 6 combolistscrollers[0].x += 34;
26277 6 }
26278 6 drawmode_btn.x = combolist_window.x-drawmode_wid;
26279 6 drawmode_btn.y = 0;
26280 6 drawmode_btn.w = drawmode_wid;
26281 6 drawmode_btn.h = mapscreen_y;
26282
26283 6 compactbtn.w = text_length(guifont,"> Compact")+10;
26284 6 compactbtn.x = drawmode_btn.x-compactbtn.w;
26285 6 compactbtn.y = drawmode_btn.y;
26286 6 compactbtn.h = drawmode_btn.h;
26287
26288
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 for(int32_t i=0; i<=8; i++)
26289 {
26290 54 map_page_bar[i].w = 48;
26291 54 map_page_bar[i].x = mapscreen_x+(i*48);
26292 54 map_page_bar[i].y = mapscreen_y+(11*16*mapscreensize);
26293 54 map_page_bar[i].h = text_height(guifont)+12;
26294 54 }
26295
26296 6 minimap.w=7+48*3;
26297 6 minimap.h=16+27*3;
26298
26299 6 layer_panel.x=map_page_bar[6].x;
26300 6 layer_panel.y=map_page_bar[0].y;
26301 6 layer_panel.w=combolist_window.x - layer_panel.x;
26302 6 layer_panel.h=map_page_bar[0].h;
26303 6 layerpanel_buttonwidth = 51;
26304 6 layerpanel_buttonheight = layer_panel.h;
26305 6 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
26306 6 layerpanel_checkbox_wid = 15;
26307
26308 6 minimap.x=3;
26309 6 minimap.y=layer_panel.y+layer_panel.h+4;
26310
26311 6 real_minimap.x = minimap.x+3;
26312 6 real_minimap.y = minimap.y+5;
26313 6 real_minimap.w = 16;
26314 6 real_minimap.h = 9;
26315 6 real_minimap.xscale = 9;
26316 6 real_minimap.yscale = 9;
26317 6 real_minimap.fw = real_minimap.xscale*8;
26318 6 real_minimap.fh = real_minimap.yscale*8;
26319
26320 6 int upscale_mm = 3;
26321 6 int xwid = real_minimap.tw()*(upscale_mm-1);
26322 6 int xhei = real_minimap.th()*(upscale_mm-1);
26323 6 minimap_zoomed.set(minimap.x, minimap.y-xhei, minimap.w+xwid, minimap.h+xhei+4);
26324 6 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
26325 6 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
26326 6 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
26327
26328 6 screrrorpos.x = combolist_window.x - 3;
26329 6 screrrorpos.y = layer_panel.y - 16;
26330
26331 6 mouse_scroll_h=10;
26332
26333 6 favorites_list.x=favorites_window.x+8;
26334 6 favorites_list.y=favorites_window.y+16;
26335 6 favorites_list.xscale = 16;
26336 6 favorites_list.yscale = 16;
26337 6 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
26338 6 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
26339
26340 6 commands_list.w=4;
26341
26342 6 int bh = commands_list.yscale;
26343 6 int bw = 26;
26344 6 commands_window.w=commands_list.w*commands_list.xscale+10+bw;
26345 6 commands_window.x=combolist_window.x-commands_window.w;
26346 6 commands_window.y=layer_panel.y+layer_panel.h;
26347 6 commands_window.h=zq_screen_h-commands_window.y;
26348 6 int bx = commands_window.x+2;
26349
26350 6 commands_list.y=commands_window.y+4;
26351 6 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
26352 6 commands_list.x=bx+bw;
26353
26354 6 commands_zoombtn.w = bw;
26355 6 commands_zoombtn.h = bh;
26356 6 commands_zoombtn.x = bx;
26357 6 commands_zoombtn.y = commands_list.y;
26358
26359 6 commands_infobtn.w = bw;
26360 6 commands_infobtn.h = bh;
26361 6 commands_infobtn.x = bx;
26362 6 commands_infobtn.y = commands_zoombtn.y + commands_infobtn.h;
26363
26364 6 commands_x.w = bw;
26365 6 commands_x.h = bh;
26366 6 commands_x.x = bx;
26367 6 commands_x.y = commands_infobtn.y + commands_x.h;
26368
26369 6 commands_txt.clear();
26370
26371 6 main_panel.x = 0;
26372 6 main_panel.y = layer_panel.y+layer_panel.h;
26373 6 main_panel.w = commands_window.x - main_panel.x;
26374 6 main_panel.h = 76+32;
26375 6 preview_panel = main_panel;
26376 6 preview_panel.x = 0;
26377 6 preview_panel.w = commands_window.x - preview_panel.x;
26378
26379 6 preview_text.x = preview_panel.x+3;
26380 6 preview_text.y = preview_panel.y+3;
26381 6 preview_text.w = 2;
26382 6 preview_text.h = 6;
26383 6 preview_text.xscale = 10;
26384 6 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
26385
26386 6 panel_align = 1;
26387 6 int swapbtnw = 32, swapbtnh = 20;
26388 6 int swapbtnx = main_panel.x+main_panel.tw()-swapbtnw;
26389 6 squarepanel_swap_btn.set(swapbtnx, zq_screen_h-swapbtnh, swapbtnw, swapbtnh);
26390
26391 6 int sqx = minimap.x+minimap.tw();
26392 6 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
26393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(compact_square_panels)
26394 {
26395 int cmpy = main_panel.y+(main_panel.th()/2);
26396 squarepanel_up_btn.set(swapbtnx, cmpy-swapbtnh, swapbtnw, swapbtnh);
26397 squarepanel_down_btn.set(swapbtnx, cmpy, swapbtnw, swapbtnh);
26398
26399 txtoffs_single.x = 18;
26400 txtoffs_single.y = 36;
26401 txtoffs_double_1.x = 18;
26402 txtoffs_double_1.y = 36;
26403 txtoffs_double_2.x = 18;
26404 txtoffs_double_2.y = 36 + text_height(get_custom_font(CFONT_GUI));
26405
26406 //Clear them all- if they stay cleared, they are invisible.
26407 itemsqr_pos.clear();
26408 stairsqr_pos.clear();
26409 warparrival_pos.clear();
26410 flagsqr_pos.clear();
26411 enemy_prev_pos.clear();
26412 for(int q = 0; q < 4; ++q)
26413 warpret_pos[q].clear();
26414
26415 int sqr_x1 = sqx+12;
26416 int sqr_y1 = main_panel.y+12;
26417 int sqr_xoffs = (16*2)+4 + 12;
26418 switch(compact_active_panel)
26419 {
26420 case 0: //Warp Squares
26421 {
26422 int x = sqr_x1;
26423 for(int q = 0; q < 4; ++q)
26424 {
26425 warpret_pos[q].set(x,sqr_y1,(16*2)+4,(16*2)+4);
26426 x += sqr_xoffs;
26427 }
26428 break;
26429 }
26430 case 1: //Other Squares
26431 {
26432 itemsqr_pos.set(sqr_x1+(sqr_xoffs*0), sqr_y1, (16*2)+4,(16*2)+4);
26433 stairsqr_pos.set(sqr_x1+(sqr_xoffs*1), sqr_y1, (16*2)+4,(16*2)+4);
26434 warparrival_pos.set(sqr_x1+(sqr_xoffs*2), sqr_y1, (16*2)+4,(16*2)+4);
26435 flagsqr_pos.set(sqr_x1+(sqr_xoffs*3), sqr_y1, (16*2)+4,(16*2)+4);
26436 break;
26437 }
26438 case 2: //Enemy Preview
26439 {
26440 enemy_prev_pos.set(sqr_x1, sqr_y1, 5, 2, 32, 32);
26441 break;
26442 }
26443 }
26444 }
26445 else
26446 {
26447 6 squarepanel_up_btn.clear();
26448 6 squarepanel_down_btn.clear();
26449 6 txtoffs_single.x = 10;
26450 6 txtoffs_single.y = 22;
26451 6 txtoffs_double_1.x = 10;
26452 6 txtoffs_double_1.y = 22;
26453 6 txtoffs_double_2.x = 10;
26454 6 txtoffs_double_2.y = 30;
26455
26456
26457 6 int sqr_x1 = sqx+24;
26458 6 int sqr_y1 = main_panel.y+12;
26459 6 int sqr_y2 = sqr_y1+42;
26460 6 int sqr_xdist = 32;
26461 6 itemsqr_pos.set(sqr_x1+(sqr_xdist*0),sqr_y1,20,20);
26462 6 stairsqr_pos.set(sqr_x1+(sqr_xdist*1),sqr_y1,20,20);
26463 6 warparrival_pos.set(sqr_x1+(sqr_xdist*2),sqr_y1,20,20);
26464 6 flagsqr_pos.set(sqr_x1+(sqr_xdist*3),sqr_y1,20,20);
26465
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(auto q = 0; q < 4; ++q)
26466 {
26467 24 warpret_pos[q].set(sqr_x1+(sqr_xdist*q),sqr_y2,20,20);
26468 24 }
26469 6 enemy_prev_pos.set(sqr_x1+(sqr_xdist*4), sqr_y1, 4, 3, 16, 16);
26470 6 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
26471 6 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
26472 }
26473
26474 6 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
26475 6 combopool_preview.x=comboaliaslist[0].x;
26476 6 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
26477 6 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
26478 6 combopool_preview.h=zq_screen_h-8-combopool_preview.y;
26479 6 combopool_preview.w -= combopool_preview.w%16;
26480 6 combopool_preview.h -= combopool_preview.h%16;
26481
26482 6 FONT* tfont = get_zc_font(font_lfont_l);
26483 6 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
26484 6 combopool_prevbtn.h = 11;
26485 6 combopool_prevbtn.x = combopool_preview.x;
26486 6 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
26487
26488 6 mappage_count = 6;
26489
26490 6 txfont = get_zc_font(font_lfont_l);
26491 6 combo_preview_text1.set(combo_preview.x-5,combo_preview.y,1,3,1,text_height(txfont));
26492 6 combo_preview_text2.clear();
26493
26494 6 favorites_x.w = 17;
26495 6 favorites_infobtn.w = 17;
26496 6 favorites_zoombtn.w = 17;
26497 6 favorites_pgleft.w = 17;
26498 6 favorites_pgright.w = 17;
26499 6 }
26500 else
26501 {
26502 num_combo_cols = 4;
26503 combo_col_scale = 16;
26504 if(large_merged_combopane)
26505 {
26506 num_combo_cols = 2;
26507 combo_col_scale = 32;
26508 }
26509
26510 mapscreen_x=0;
26511 mapscreen_y=dialogs[0].h;
26512 mapscreensize=2;
26513 showedges=1;
26514 showallpanels=0;
26515
26516 blackout_color=8;
26517
26518 favorites_window.h=136;
26519 favorites_window.y=zq_screen_h-favorites_window.h;
26520
26521 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreensize);
26522 combolist_window.w=zq_screen_w-mapscr_wid;
26523 combolist_window.x=zq_screen_w-combolist_window.w;
26524 combolist_window.y=0;
26525 combolist_window.h=favorites_window.y-combolist_window.y;
26526
26527 favorites_window.x=combolist_window.x;
26528 favorites_window.w=combolist_window.w;
26529
26530 combo_preview.x=(zq_screen_w-(combolist_window.w/2))-40;
26531 combo_preview.y=combolist_window.y+6;
26532 combo_preview.w=32;
26533 combo_preview.h=32;
26534 combo_preview2 = combo_preview;
26535 combo_preview2.x += 48;
26536
26537 auto col_wid = 4*combo_col_scale;
26538 auto cols_wid = col_wid * num_combo_cols;
26539 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
26540 for(auto q = 0; q < num_combo_cols; ++q)
26541 {
26542 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
26543 combolist[q].y=combolist_window.y+60;
26544 combolist[q].w=4;
26545 combolist[q].h=large_merged_combopane ? 15 : 30;
26546 combolist[q].xscale = combo_col_scale;
26547 combolist[q].yscale = combo_col_scale;
26548
26549 comboaliaslist[q].x=combolist[q].x;
26550 comboaliaslist[q].y=combolist[q].y;
26551 comboaliaslist[q].w=4;
26552 comboaliaslist[q].h=large_merged_combopane ? 12 : 25;
26553 comboaliaslist[q].xscale = combo_col_scale;
26554 comboaliaslist[q].yscale = combo_col_scale;
26555
26556 combolistscrollers[q].w=2;
26557 combolistscrollers[q].h=1;
26558 combolistscrollers[q].xscale=11;
26559 combolistscrollers[q].yscale=11;
26560 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
26561 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-2;
26562 }
26563
26564 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
26565 comboalias_preview.h=64;
26566 comboalias_preview.w=64;
26567 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
26568
26569 combo_merge_btn.w = 20;
26570 combo_merge_btn.h = 20;
26571 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
26572 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
26573 squarepanel_swap_btn.clear();
26574 squarepanel_up_btn.clear();
26575 squarepanel_down_btn.clear();
26576
26577 drawmode_btn.x = combolist_window.x-drawmode_wid;
26578 drawmode_btn.y = 0;
26579 drawmode_btn.w = drawmode_wid;
26580 drawmode_btn.h = mapscreen_y;
26581
26582 compactbtn.w = text_length(guifont,"> Compact")+10;
26583 compactbtn.x = drawmode_btn.x-compactbtn.w;
26584 compactbtn.y = drawmode_btn.y;
26585 compactbtn.h = drawmode_btn.h;
26586
26587 for(int32_t i=0; i<=8; i++)
26588 {
26589 map_page_bar[i].x = mapscreen_x+(i*16*2*mapscreensize);
26590 map_page_bar[i].y = mapscreen_y+((showedges?13:11)*16*mapscreensize);
26591 map_page_bar[i].w = 64;
26592 map_page_bar[i].h = text_height(guifont)+12;
26593 }
26594
26595 minimap.w=7+48*3;
26596 minimap.h=16+27*3;
26597
26598 layer_panel.x=map_page_bar[0].x;
26599 layer_panel.y=map_page_bar[0].y+map_page_bar[0].h;
26600 layer_panel.w=map_page_bar[8].x+map_page_bar[8].w;
26601 layer_panel.h=text_height(guifont)+8;
26602 layerpanel_buttonwidth = 58;
26603 layerpanel_buttonheight = layer_panel.h;
26604 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
26605 layerpanel_checkbox_wid = 14;
26606
26607 commands_list.w=4;
26608 commands_window.w=commands_list.w*commands_list.xscale+16;
26609 commands_window.x=combolist_window.x-commands_window.w;
26610 commands_window.y=layer_panel.y+layer_panel.h;
26611 commands_window.h=zq_screen_h-commands_window.y;
26612
26613 //buttons panel
26614 main_panel.x = 0;
26615 main_panel.y = layer_panel.y+layer_panel.h;
26616 main_panel.w = commands_window.x - main_panel.x;
26617 main_panel.h = zq_screen_h - main_panel.y;
26618 preview_panel = main_panel;
26619
26620 preview_text.x = preview_panel.x+3;
26621 preview_text.y = preview_panel.y+3;
26622 preview_text.w = 1;
26623 preview_text.h = 12;
26624 preview_text.xscale = 10;
26625 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
26626
26627 minimap.x=3;
26628 minimap.y=main_panel.y+4;
26629
26630 real_minimap.x = minimap.x+3;
26631 real_minimap.y = minimap.y+5;
26632 real_minimap.w = 16;
26633 real_minimap.h = 9;
26634 real_minimap.xscale = 9;
26635 real_minimap.yscale = 9;
26636 real_minimap.fw = real_minimap.xscale*8;
26637 real_minimap.fh = real_minimap.yscale*8;
26638
26639 int upscale_mm = 4;
26640 int xwid = real_minimap.tw()*(upscale_mm-1);
26641 int xhei = real_minimap.th()*(upscale_mm-1);
26642 int zh = minimap.h+xhei+4;
26643 minimap_zoomed.set(minimap.x, zq_screen_h-zh, minimap.w+xwid, zh);
26644 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
26645 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
26646 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
26647
26648 screrrorpos.x = 575;
26649 screrrorpos.y = 388;
26650
26651 mouse_scroll_h=10;
26652
26653 favorites_list.x=favorites_window.x+8;
26654 favorites_list.y=favorites_window.y+16;
26655 favorites_list.xscale = 16;
26656 favorites_list.yscale = 16;
26657 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
26658 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
26659
26660 int bh = 16;
26661 int by = commands_window.y+4;
26662 commands_list.y=by+bh;
26663 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
26664 commands_list.x=commands_window.x+8;
26665
26666 commands_x.w = 20;
26667 commands_x.h = bh;
26668 commands_x.x = commands_list.x + commands_list.tw() - commands_x.w;
26669 commands_x.y = by;
26670
26671 commands_infobtn.w = 20;
26672 commands_infobtn.h = bh;
26673 commands_infobtn.x = commands_x.x - commands_infobtn.w;
26674 commands_infobtn.y = by;
26675
26676 commands_zoombtn.w = 20;
26677 commands_zoombtn.h = bh;
26678 commands_zoombtn.x = commands_infobtn.x - commands_zoombtn.w;
26679 commands_zoombtn.y = by;
26680
26681 commands_txt.x = commands_list.x;
26682 commands_txt.y = by+(bh-text_height(get_zc_font(font_lfont_l)))/2;
26683
26684 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
26685 favorites_x.y = favorites_list.y-15;
26686
26687 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
26688 favorites_infobtn.y = favorites_x.y;
26689
26690 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
26691 favorites_zoombtn.y = favorites_infobtn.y;
26692
26693 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
26694 favorites_pgright.y = favorites_zoombtn.y;
26695
26696 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
26697 favorites_pgleft.y = favorites_pgleft.y;
26698
26699 txtoffs_single.x = 22;
26700 txtoffs_single.y = 6;
26701 txtoffs_double_1.x = 22;
26702 txtoffs_double_1.y = 2;
26703 txtoffs_double_2.x = 22;
26704 txtoffs_double_2.y = 10;
26705 panel_align = 0;
26706
26707 int sqx = minimap.x+minimap.tw();
26708 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
26709 int x2 = sqx+4;
26710 int x1 = x2 - (20+(8*3)+2);
26711 int y1 = main_panel.y+10;
26712 int sw = 20, sh = 20;
26713 int offs = sh+4;
26714
26715 itemsqr_pos.set(x2,y1+(0*offs),sw,sh);
26716 flagsqr_pos.set(x2,y1+(1*offs),sw,sh);
26717 stairsqr_pos.set(x2,y1+(2*offs),sw,sh);
26718 warparrival_pos.set(x2,y1+(6*offs),sw,sh);
26719
26720 enemy_prev_pos.x = main_panel.x+14;
26721 enemy_prev_pos.y = main_panel.y+12 + minimap.h;
26722 enemy_prev_pos.w = 4;
26723 enemy_prev_pos.h = 3;
26724 enemy_prev_pos.xscale = 16;
26725 enemy_prev_pos.yscale = 16;
26726 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
26727 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
26728
26729 warpret_pos[0].set(x1,y1+(4*offs),sw,sh);
26730 warpret_pos[1].set(x1,y1+(5*offs),sw,sh);
26731 warpret_pos[2].set(x2,y1+(4*offs),sw,sh);
26732 warpret_pos[3].set(x2,y1+(5*offs),sw,sh);
26733
26734 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
26735 combopool_preview.x=comboaliaslist[0].x;
26736 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
26737 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
26738 combopool_preview.h=(favorites_window.y-combopool_preview.y);//+favorites_window.h-10;
26739 combopool_preview.w -= combopool_preview.w%16;
26740 combopool_preview.h -= combopool_preview.h%16;
26741
26742 FONT* tfont = get_zc_font(font_lfont_l);
26743 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
26744 combopool_prevbtn.h = 11;
26745 combopool_prevbtn.x = combopool_preview.x;
26746 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
26747
26748 mappage_count = 9;
26749
26750 txfont = get_zc_font(font_lfont_l);
26751 combo_preview_text1.set(combo_preview.x-9,combo_preview.y,1,3,1,text_height(txfont));
26752 combo_preview_text2.set(combo_preview2.x+combo_preview2.w+8,combo_preview2.y,1,3,1,text_height(txfont));
26753
26754 favorites_x.w = 30;
26755 favorites_infobtn.w = 30;
26756 favorites_zoombtn.w = 30;
26757 favorites_pgleft.w = 30;
26758 favorites_pgright.w = 30;
26759 }
26760 //Same in all modes
26761 {
26762
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(is_compact ? compact_zoomed_cmd : large_zoomed_cmd)
26763 {
26764 6 commands_list.w /= 2;
26765 6 commands_list.xscale *= 2;
26766 6 }
26767
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(is_compact ? compact_zoomed_fav : large_zoomed_fav)
26768 {
26769
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(favorites_list.w%2)
26770 favorites_list.x += (favorites_list.xscale / 2);
26771 6 favorites_list.xscale *= 2;
26772 6 favorites_list.yscale *= 2;
26773 6 favorites_list.w /= 2;
26774 6 favorites_list.h /= 2;
26775 6 }
26776
26777 6 favorites_x.h = 14;
26778 6 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
26779 6 favorites_x.y = favorites_list.y-15;
26780
26781 6 favorites_infobtn.h = favorites_x.h;
26782 6 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
26783 6 favorites_infobtn.y = favorites_x.y;
26784
26785 6 favorites_zoombtn.h = favorites_infobtn.h;
26786 6 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
26787 6 favorites_zoombtn.y = favorites_infobtn.y;
26788
26789 6 favorites_pgright.h = favorites_zoombtn.h;
26790 6 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
26791 6 favorites_pgright.y = favorites_zoombtn.y;
26792
26793 6 favorites_pgleft.h = favorites_pgright.h;
26794 6 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
26795 6 favorites_pgleft.y = favorites_pgright.y;
26796
26797 6 mainbar.x = dialogs[0].x+dialogs[0].w;
26798 6 mainbar.y = 0;
26799 6 mainbar.w = compactbtn.x-mainbar.x;
26800 6 mainbar.h = drawmode_btn.h;
26801 }
26802
26803 //Ensure current combo list selected is valid
26804 6 current_combolist=vbound(current_combolist,0,num_combo_cols-1);
26805 6 current_comboalist=vbound(current_comboalist,0,num_combo_cols-1);
26806 6 current_cpoollist=vbound(current_cpoollist,0,num_combo_cols-1);
26807 6 current_cautolist = vbound(current_cautolist, 0, num_combo_cols - 1);
26808
26809 //Generate bitmaps
26810 6 init_bitmap(&mapscreenbmp,16*(showedges?18:16),16*(showedges?13:11));
26811 6 init_bitmap(&brushbmp,256*mapscreensize,176*mapscreensize);
26812 6 init_bitmap(&brushscreen,(256+(showedges?16:0))*mapscreensize,(176+(showedges?16:0))*mapscreensize);
26813
26814 6 init_bitmap(&screen2,zq_screen_w,zq_screen_h);
26815 6 init_bitmap(&tmp_scr,zq_screen_w,zq_screen_h);
26816 6 init_bitmap(&menu1,zq_screen_w,zq_screen_h);
26817 6 init_bitmap(&menu3,zq_screen_w,zq_screen_h);
26818
26819 6 center_zq_class_dialogs();
26820 6 center_zq_custom_dialogs();
26821 6 center_zq_files_dialogs();
26822 6 center_zq_subscreen_dialogs();
26823 6 center_zq_tiles_dialogs();
26824 6 center_zquest_dialogs();
26825
26826 6 aspect_ratio = zq_screen_h / double(zq_screen_w);
26827
26828 6 mmap_init();
26829 6 }
26830
26831 9 void remove_locked_params_on_exit()
26832 {
26833 9 al_trace("Removing timers. \n");
26834 9 remove_int(fps_callback);
26835 9 remove_int(dclick_check);
26836 9 }
26837
26838 9 void destroy_bitmaps_on_exit()
26839 {
26840 9 al_trace("Cleaning bitmaps...");
26841 9 destroy_bitmap(screen2);
26842 9 destroy_bitmap(tmp_scr);
26843 9 destroy_bitmap(menu1);
26844 9 destroy_bitmap(menu3);
26845 9 destroy_bitmap(mapscreenbmp);
26846 9 destroy_bitmap(dmapbmp_small);
26847 9 destroy_bitmap(dmapbmp_large);
26848 9 destroy_bitmap(brushbmp);
26849 9 destroy_bitmap(brushscreen);
26850 9 al_trace("...");
26851
26852
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 9 times.
441 for(int32_t i=0; i<MOUSE_BMP_MAX*4; i++)
26853 {
26854 432 destroy_bitmap(mouse_bmp[i/4][i%4]);
26855 432 destroy_bitmap(mouse_bmp_1x[i/4][i%4]);
26856 432 }
26857
26858
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 9 times.
297 for(int32_t i=0; i<ICON_BMP_MAX*4; i++)
26859 288 destroy_bitmap(icon_bmp[i/4][i%4]);
26860
26861
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 9 times.
585 for(int32_t i=0; i<16*4; i++)
26862 576 destroy_bitmap(flag_bmp[i/4][i%4]);
26863
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(int32_t i=0; i<2; i++)
26864 18 destroy_bitmap(select_bmp[i]);
26865
26866
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 9 times.
81 for(int32_t i=0; i<MAXARROWS; i++)
26867 72 destroy_bitmap(arrow_bmp[i]);
26868
26869 9 al_trace(" OK. \n");
26870 9 }
26871
26872
26873 9 void quit_game()
26874 {
26875 9 set_last_timed_save(nullptr);
26876 9 save_config_file();
26877 9 zc_set_palette(black_palette);
26878 9 zc_stop_midi();
26879
26880 9 remove_locked_params_on_exit();
26881
26882 9 al_trace("Cleaning sfx. \n");
26883
26884
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WAV_COUNT; i++)
26885 {
26886
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(customsfxdata[i].data!=NULL)
26887 {
26888 // delete [] customsfxdata[i].data;
26889 2295 free(customsfxdata[i].data);
26890 2295 }
26891
26892
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete [] sfx_string[i];
26893 2304 }
26894
26895
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXWPNS; i++)
26896 {
26897
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete [] weapon_string[i];
26898 2304 }
26899
26900
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
26901 {
26902
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 delete [] item_string[i];
26903 2304 }
26904
26905
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
26906 {
26907
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 delete [] guy_string[i];
26908 4608 }
26909
26910 9 al_trace("Cleaning script buffer. \n");
26911
26912
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
26913 {
26914
2/4
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4608 times.
4608 if(ffscripts[i]!=NULL) delete ffscripts[i];
26915 4608 }
26916
26917
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
26918 {
26919
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(itemscripts[i]!=NULL) delete itemscripts[i];
26920 2304 }
26921
26922
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
26923 {
26924
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(guyscripts[i]!=NULL) delete guyscripts[i];
26925 2304 }
26926
26927
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
26928 {
26929
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
26930 2304 }
26931
26932
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
26933 {
26934
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
26935 2304 }
26936
26937
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
26938 {
26939
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(screenscripts[i]!=NULL) delete screenscripts[i];
26940 2304 }
26941
26942
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
36 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
26943 {
26944
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
27 if(globalscripts[i]!=NULL) delete globalscripts[i];
26945 27 }
26946
26947
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 9 times.
54 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
26948 {
26949
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(playerscripts[i]!=NULL) delete playerscripts[i];
26950 45 }
26951
26952
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
26953 {
26954
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
26955 2304 }
26956
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
26957 {
26958
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
26959 2304 }
26960
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
26961 {
26962
2/4
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4608 times.
4608 if(comboscripts[i]!=NULL) delete comboscripts[i];
26963 4608 }
26964
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
26965 {
26966
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2304 times.
2304 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
26967 2304 }
26968
26969 9 al_trace("Cleaning qst buffers. \n");
26970 9 del_qst_buffers();
26971
26972
26973 9 al_trace("Cleaning midis. \n");
26974
26975
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(customtunes)
26976 {
26977
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
26978 2304 customtunes[i].reset();
26979
26980 9 free(customtunes);
26981 9 }
26982
26983 9 al_trace("Cleaning undotilebuf. \n");
26984
26985 9 undocombobuf.clear();
26986
26987
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(newundotilebuf)
26988 {
26989
2/2
✓ Branch 0 taken 1501500 times.
✓ Branch 1 taken 7 times.
1501507 for(int32_t i=0; i<NEWMAXTILES; i++)
26990
1/2
✓ Branch 0 taken 1501500 times.
✗ Branch 1 not taken.
1501500 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
26991
26992 7 free(newundotilebuf);
26993 7 }
26994
26995
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(filepath) free(filepath);
26996
26997
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(datapath) free(datapath);
26998
26999
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(midipath) free(midipath);
27000
27001
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(imagepath) free(imagepath);
27002
27003
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(tmusicpath) free(tmusicpath);
27004
27005
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(last_timed_save) free(last_timed_save);
27006
27007 9 destroy_bitmaps_on_exit();
27008 9 }
27009
27010 void quit_game2()
27011 {
27012 set_last_timed_save(nullptr);
27013 save_config_file();
27014 zc_set_palette(black_palette);
27015 zc_stop_midi();
27016
27017 remove_locked_params_on_exit();
27018
27019 al_trace("Cleaning sfx. \n");
27020
27021 for(int32_t i=0; i<WAV_COUNT; i++)
27022 {
27023 if(customsfxdata[i].data!=NULL)
27024 {
27025 // delete [] customsfxdata[i].data;
27026 free(customsfxdata[i].data);
27027 }
27028
27029 delete [] sfx_string[i];
27030 }
27031
27032 for(int32_t i=0; i<MAXWPNS; i++)
27033 {
27034 delete [] weapon_string[i];
27035 }
27036
27037 for(int32_t i=0; i<MAXITEMS; i++)
27038 {
27039 delete [] item_string[i];
27040 }
27041
27042 for(int32_t i=0; i<eMAXGUYS; i++)
27043 {
27044 delete [] guy_string[i];
27045 }
27046
27047 al_trace("Cleaning script buffer. \n");
27048
27049 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
27050 {
27051 if(ffscripts[i]!=NULL) delete ffscripts[i];
27052 }
27053
27054 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
27055 {
27056 if(itemscripts[i]!=NULL) delete itemscripts[i];
27057 }
27058
27059 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
27060 {
27061 if(guyscripts[i]!=NULL) delete guyscripts[i];
27062 }
27063
27064 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27065 {
27066 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
27067 }
27068
27069 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
27070 {
27071 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
27072 }
27073
27074 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
27075 {
27076 if(screenscripts[i]!=NULL) delete screenscripts[i];
27077 }
27078
27079 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
27080 {
27081 if(globalscripts[i]!=NULL) delete globalscripts[i];
27082 }
27083
27084 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
27085 {
27086 if(playerscripts[i]!=NULL) delete playerscripts[i];
27087 }
27088
27089 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
27090 {
27091 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
27092 }
27093 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
27094 {
27095 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
27096 }
27097 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
27098 {
27099 if(comboscripts[i]!=NULL) delete comboscripts[i];
27100 }
27101 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
27102 {
27103 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
27104 }
27105
27106 al_trace("Cleaning qst buffers. \n");
27107 del_qst_buffers();
27108
27109
27110 al_trace("Cleaning midis. \n");
27111
27112 if(customtunes)
27113 {
27114 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
27115 customtunes[i].reset();
27116
27117 free(customtunes);
27118 }
27119
27120 al_trace("Cleaning undotilebuf. \n");
27121
27122 undocombobuf.clear();
27123
27124 if(newundotilebuf)
27125 {
27126 for(int32_t i=0; i<NEWMAXTILES; i++)
27127 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
27128
27129 free(newundotilebuf);
27130 }
27131
27132 if(filepath) free(filepath);
27133
27134 if(datapath) free(datapath);
27135
27136 if(midipath) free(midipath);
27137
27138 if(imagepath) free(imagepath);
27139
27140 if(tmusicpath) free(tmusicpath);
27141
27142 if(last_timed_save) free(last_timed_save);
27143 }
27144
27145 6 void center_zquest_dialogs()
27146 {
27147 6 jwin_center_dialog(assignscript_dlg);
27148 6 jwin_center_dialog(autolayer_dlg);
27149 6 jwin_center_dialog(cpage_dlg);
27150 6 center_zq_cset_dialogs();
27151 6 jwin_center_dialog(change_track_dlg);
27152 6 jwin_center_dialog(csetfix_dlg);
27153 6 jwin_center_dialog(dmapmaps_dlg);
27154 6 center_zq_door_dialogs();
27155 6 jwin_center_dialog(editcomboa_dlg);
27156 6 jwin_center_dialog(editinfo_dlg);
27157 6 jwin_center_dialog(editmidi_dlg);
27158 6 jwin_center_dialog(editmusic_dlg);
27159 6 jwin_center_dialog(editshop_dlg);
27160 6 jwin_center_dialog(elist_dlg);
27161 6 jwin_center_dialog(enemy_dlg);
27162 6 jwin_center_dialog(ffcombo_sel_dlg);
27163 6 jwin_center_dialog(getnum_dlg);
27164 6 jwin_center_dialog(glist_dlg);
27165 6 jwin_center_dialog(layerdata_dlg);
27166 6 jwin_center_dialog(list_dlg);
27167 6 jwin_center_dialog(loadmap_dlg);
27168 6 jwin_center_dialog(mapstyles_dlg);
27169 6 jwin_center_dialog(misccolors_dlg);
27170 6 jwin_center_dialog(newcomboa_dlg);
27171 6 jwin_center_dialog(orgcomboa_dlg);
27172 6 jwin_center_dialog(path_dlg);
27173 6 jwin_center_dialog(pattern_dlg);
27174 6 jwin_center_dialog(screen_pal_dlg);
27175 6 jwin_center_dialog(secret_dlg);
27176 6 jwin_center_dialog(selectdmap_dlg);
27177 6 jwin_center_dialog(selectmidi_dlg);
27178 6 jwin_center_dialog(selectmusic_dlg);
27179 6 jwin_center_dialog(sfxlist_dlg);
27180 6 jwin_center_dialog(sfx_edit_dlg);
27181 6 jwin_center_dialog(showpal_dlg);
27182 6 jwin_center_dialog(strlist_dlg);
27183 6 jwin_center_dialog(template_dlg);
27184 6 jwin_center_dialog(tp_dlg);
27185 6 jwin_center_dialog(under_dlg);
27186 6 jwin_center_dialog(tilewarp_dlg);
27187 6 jwin_center_dialog(sidewarp_dlg);
27188 6 jwin_center_dialog(warpring_dlg);
27189 6 jwin_center_dialog(wlist_dlg);
27190 6 center_zscript_dialogs();
27191 6 }
27192
27193
27194 void animate_coords()
27195 {
27196 coord_frame=(coord_timer>>3)&3;
27197
27198 if(++coord_timer>=(1<<5))
27199 {
27200 coord_timer=0;
27201 }
27202 }
27203
27204 static const char *help_list[] =
27205 {
27206 "PREVIEW MODE",
27207 "PgUp/PgDn - Scroll through hotkey list",
27208 "Esc/Enter - Exit Preview Mode",
27209 "R - Restore screen to original state",
27210 "C - Toggle combo cycling On/Off",
27211 "S - Trigger screen secrets",
27212 "Q/W/F - These still work",
27213 "P - Pause everything",
27214 "A - Advance frame-by-frame",
27215 "1-4 - Trigger tile warp A-D",
27216 "5-8 - Trigger side warp A-D",
27217 "9 - Enable timed warps",
27218 "",
27219 "",
27220 };
27221
27222 void do_previewtext()
27223 {
27224 FONT* oldfont = font;
27225 font = get_zc_font(font_lfont_l);
27226
27227 //Put in help areas
27228 auto& sqr = preview_text;
27229 int ind = 0, len = 0;
27230 for(int q = 0; q < 12; ++q)
27231 {
27232 int l = text_length(font, help_list[q]);
27233 if(len < l) len = l;
27234 }
27235 sqr.xscale = len+2;
27236 sqr.yscale = text_height(font);
27237 for(int col = 0; col < sqr.w; ++col)
27238 {
27239 for(int row = 0; row < sqr.h; ++row)
27240 {
27241 auto& line = sqr.subsquare(col,row);
27242 textprintf_ex(menu1,font,line.x,line.y,jwin_pal[jcTEXTFG],-1,"%s",help_list[ind++]);
27243 }
27244 }
27245
27246 font = oldfont;
27247 }
27248
27249
27250 bool reload_fonts = false;
27251 void run_zq_frame()
27252 {
27253 if(reload_fonts)
27254 {
27255 init_custom_fonts();
27256 load_size_poses();
27257 reload_fonts = false;
27258 }
27259
27260 domouse();
27261 custom_vsync();
27262 refresh(rCLEAR|rALL);
27263 }
27264 6 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c)
27265 {
27266
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 switch(msg)
27267 {
27268 case MSG_VSYNC:
27269 run_zq_frame();
27270 break;
27271 case MSG_GOTMOUSE:
27272 case MSG_XCHAR:
27273 ComboBrushPause=1;
27274 refresh(rMAP);
27275 ComboBrushPause=0;
27276 clear_tooltip();
27277 break;
27278 }
27279
27280 6 return GuiMenu::proc(msg,d,c);
27281 }
27282
27283 bool prv_press=false;
27284
27285 void dopreview()
27286 {
27287 refresh(rMAP);
27288
27289 while(!(gui_mouse_b()))
27290 {
27291 if(keypressed())
27292 {
27293 if(!prv_press)
27294 {
27295 prv_press=true;
27296
27297 switch(readkey()>>8)
27298 {
27299 case KEY_ESC:
27300 case KEY_ENTER:
27301 case KEY_ENTER_PAD:
27302 goto finished;
27303 break;
27304
27305 case KEY_F:
27306 Flags^=cFLAGS;
27307 refresh(rMAP);
27308 break;
27309
27310 case KEY_R:
27311 onReloadPreview();
27312 break;
27313
27314 case KEY_S:
27315 onSecretsPreview();
27316 break;
27317
27318 case KEY_C:
27319 onCopy();
27320 break;
27321
27322 case KEY_A:
27323 onAKey();
27324 break;
27325
27326 case KEY_P:
27327 onP();
27328 break;
27329
27330 case KEY_L:
27331 onShowDarkness();
27332 break;
27333
27334 case KEY_1:
27335 Map.prv_dowarp(0,0);
27336 prv_warp=0;
27337 break;
27338
27339 case KEY_2:
27340 Map.prv_dowarp(0,1);
27341 prv_warp=0;
27342 break;
27343
27344 case KEY_3:
27345 Map.prv_dowarp(0,2);
27346 prv_warp=0;
27347 break;
27348
27349 case KEY_4:
27350 Map.prv_dowarp(0,3);
27351 prv_warp=0;
27352 break;
27353
27354 case KEY_5:
27355 Map.prv_dowarp(1,0);
27356 prv_warp=0;
27357 break;
27358
27359 case KEY_6:
27360 Map.prv_dowarp(1,1);
27361 prv_warp=0;
27362 break;
27363
27364 case KEY_7:
27365 Map.prv_dowarp(1,2);
27366 prv_warp=0;
27367 break;
27368
27369 case KEY_8:
27370 Map.prv_dowarp(1,3);
27371 prv_warp=0;
27372 break;
27373
27374 case KEY_9:
27375 if(prv_twon)
27376 {
27377 prv_twon=0;
27378 Map.set_prvtime(0);
27379 prv_warp=0;
27380 }
27381 else
27382 {
27383 Map.set_prvtime(Map.get_prvscr()->timedwarptics);
27384 prv_twon=1;
27385 }
27386
27387 break;
27388
27389 case KEY_W:
27390 onShowWalkability();
27391 break;
27392
27393 case KEY_Q:
27394 onShowComboInfoCSet();
27395 break;
27396 }
27397 }
27398 else
27399 {
27400 readkey();
27401 }
27402 }
27403 else
27404 {
27405 prv_press=false;
27406 }
27407
27408 if(prv_warp)
27409 {
27410 Map.prv_dowarp(1,0);
27411 prv_warp=0;
27412 }
27413
27414 if(Map.get_prvfreeze())
27415 {
27416 if(Map.get_prvadvance())
27417 {
27418 custom_vsync();
27419 Map.set_prvadvance(0);
27420 }
27421 }
27422 else
27423 {
27424 custom_vsync();
27425 Map.set_prvadvance(0);
27426 }
27427
27428 refresh(rALL);
27429 }
27430
27431 finished:
27432 //Flags=of;
27433 reset_combo_animations();
27434 reset_combo_animations2();
27435 MouseSprite::set(ZQM_NORMAL);
27436 prv_mode=0;
27437 Map.set_prvcmb(0);
27438 Map.set_prvadvance(0);
27439 Map.set_prvfreeze(0);
27440 Map.set_prvtime(0);
27441 prv_warp=0;
27442 loadlvlpal(Map.getcolor());
27443 rebuild_trans_table();
27444 refresh(rMAP+rMENU);
27445
27446 while(gui_mouse_b())
27447 {
27448 /* do nothing */
27449 rest(1);
27450 }
27451 }
27452
27453 void call_vidmode_dlg();
27454 int32_t onZQVidMode()
27455 {
27456 call_vidmode_dlg();
27457 return D_O_K;
27458 }
27459
27460 bool screenIsScrolling()
27461 {
27462 return false;
27463 }
27464
27465 void write_includepaths()
27466 {
27467 FILE* f = fopen("includepaths.txt", "w");
27468 if(f)
27469 {
27470 fwrite(FFCore.includePathString,1,strlen(FFCore.includePathString),f);
27471 fclose(f);
27472 }
27473 }
27474
27475 9 int32_t save_config_file()
27476 {
27477
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (!application_has_loaded) return 0;
27478
27479 char qtnametitle[20];
27480 char qtpathtitle[20];
27481 char *datapath2=(char *)malloc(2048);
27482 char *midipath2=(char *)malloc(2048);
27483 char *imagepath2=(char *)malloc(2048);
27484 char *tmusicpath2=(char *)malloc(2048);
27485 strcpy(datapath2, datapath);
27486 strcpy(midipath2, midipath);
27487 strcpy(imagepath2, imagepath);
27488 strcpy(tmusicpath2, tmusicpath);
27489 chop_path(datapath2);
27490 chop_path(midipath2);
27491 chop_path(imagepath2);
27492 chop_path(tmusicpath2);
27493
27494 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
27495 //
27496 write_includepaths();
27497
27498 zc_set_config("zquest",data_path_name,datapath2);
27499 zc_set_config("zquest",midi_path_name,midipath2);
27500 zc_set_config("zquest",image_path_name,imagepath2);
27501 zc_set_config("zquest",tmusic_path_name,tmusicpath2);
27502
27503 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
27504 {
27505 window_width = al_get_display_width(all_get_display());
27506 window_height = al_get_display_height(all_get_display());
27507 zc_set_config("zquest","window_width",window_width);
27508 zc_set_config("zquest","window_height",window_height);
27509 }
27510 if (all_get_display() && !all_get_fullscreen_flag() && SaveWinPos)
27511 {
27512 int o_window_x, o_window_y;
27513 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
27514 zc_set_config("zquest", "window_x", o_window_x);
27515 zc_set_config("zquest", "window_y", o_window_y);
27516 }
27517
27518 byte b = 0;
27519 for(int32_t x=0; x<7; x++)
27520 {
27521 set_bit(&b,x,LayerMaskInt[x]);
27522 }
27523
27524 zc_set_config("zquest","layer_mask",b);
27525
27526 flush_config_file();
27527 #ifdef __EMSCRIPTEN__
27528 em_sync_fs();
27529 #endif
27530 free(datapath2);
27531 free(midipath2);
27532 free(imagepath2);
27533 free(tmusicpath2);
27534 return 0;
27535 9 }
27536
27537 int32_t d_timer_proc(int32_t msg, DIALOG *d, int32_t c)
27538 {
27539 //these are here to bypass compiler warnings about unused arguments
27540 c=c;
27541 d=d;
27542
27543 switch(msg)
27544 {
27545 case MSG_IDLE:
27546 #ifdef _WIN32
27547 if(zqUseWin32Proc != FALSE)
27548 win32data.Update(Frameskip); //experimental win32 fixes
27549
27550 #endif
27551
27552 // This has been crashing on Windows, and it saves plenty without it
27553 //check_autosave();
27554 break;
27555 }
27556
27557 return D_O_K;
27558 }
27559
27560 void check_autosave()
27561 {
27562 if (!first_save)
27563 return;
27564
27565 if(AutoSaveInterval>0)
27566 {
27567 time(&auto_save_time_current);
27568 auto_save_time_diff = difftime(auto_save_time_current,auto_save_time_start);
27569
27570 if(auto_save_time_diff>AutoSaveInterval*60)
27571 {
27572 MouseSprite::set(ZQM_NORMAL);
27573 replace_extension(last_timed_save, filepath, "qt0", 2047);
27574 set_last_timed_save(last_timed_save);
27575 go();
27576
27577 if((header.zelda_version != ZELDA_VERSION || header.build != VERSION_BUILD))
27578 {
27579 jwin_alert("Auto Save","This quest was saved in an older version of ZQuest.","If you wish to use the autosave feature, you must manually","save the files in this version first.","OK",NULL,13,27,get_zc_font(font_lfont));
27580 time(&auto_save_time_start);
27581 comeback();
27582 return;
27583 }
27584
27585 int32_t ret = save_quest(last_timed_save, true);
27586
27587 if(ret)
27588 {
27589 jwin_alert("Error","Timed save did not complete successfully.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
27590 set_last_timed_save(nullptr);
27591 }
27592
27593 save_config_file();
27594 time(&auto_save_time_start);
27595 comeback();
27596 }
27597 }
27598 }
27599
27600 void flushItemCache(bool) {}
27601 void ringcolor(bool forceDefault)
27602 {
27603 forceDefault=forceDefault;
27604 }
27605
27606 bool item_disabled(int32_t)
27607 {
27608 return false;
27609 }
27610
27611 int32_t onCmdExit()
27612 {
27613 // replaces onExit for the -large button command "Exit"
27614 close_button_quit = true;
27615 return 0;
27616 }
27617
27618 int32_t onQuickCompile()
27619 {
27620 if(do_compile_and_slots(1,false))
27621 {
27622 saved = false;
27623 InfoDialog("Quick Compile","Success!").show();
27624 }
27625 else
27626 {
27627 InfoDialog("Quick Compile","Failure!").show();
27628 }
27629 return 0;
27630 }
27631 int32_t onSmartCompile()
27632 {
27633 if(do_compile_and_slots(2,false))
27634 {
27635 saved = false;
27636 InfoDialog("Smart Compile","Success!").show();
27637 }
27638 else
27639 {
27640 InfoDialog("Smart Compile","Failure!").show();
27641 }
27642 return 0;
27643 }
27644
27645 int32_t strchrnum(char const* str, char c)
27646 {
27647 for(int32_t i=0; str[i]; ++i)
27648 {
27649 if(str[i]==c)
27650 {
27651 return i;
27652 }
27653 }
27654
27655 return -1;
27656 }
27657
27658 int32_t get_longest_line_length(FONT *f, char* str)
27659 {
27660 int32_t maxlen=0;
27661 char* tmpstr = str;
27662 char temp=0;
27663 int32_t t=0;
27664 int32_t new_t=-1;
27665 while(tmpstr[0])
27666 {
27667 t=strchrnum(tmpstr, '\n');
27668
27669 if(t==-1)
27670 {
27671 t=(int32_t)strlen(tmpstr);
27672 }
27673
27674 if((uint32_t)t!=strlen(tmpstr))
27675 {
27676 new_t=t+1;
27677 }
27678 else
27679 {
27680 new_t=-1;
27681 }
27682
27683 temp = tmpstr[t];
27684 tmpstr[t]=0;
27685 maxlen=zc_max(maxlen,text_length(f, tmpstr));
27686 tmpstr[t]=temp;
27687
27688 if(new_t!=-1)
27689 {
27690 tmpstr+=new_t;
27691 }
27692 else break;
27693 }
27694 return maxlen;
27695 }
27696
27697 int32_t count_lines(char const* str)
27698 {
27699 int32_t count=1;
27700
27701 for(word i=0; i<strlen(str); ++i)
27702 {
27703 if(str[i]=='\n')
27704 {
27705 ++count;
27706 }
27707 }
27708
27709 return count;
27710 }
27711
27712 void debug_pos(size_and_pos const& pos, int color)
27713 {
27714 if(pos.w < 1 || pos.h < 1)
27715 return;
27716 if(pos.xscale > 1 || pos.yscale > 1)
27717 {
27718 auto maxind = pos.w*pos.h;
27719 for(auto q = 0; q < maxind; ++q)
27720 {
27721 auto& sub = pos.subsquare(q);
27722 if(sub.x < 0) break;
27723 highlight_sqr(screen, color, sub, 1);
27724 }
27725 }
27726 else
27727 {
27728 if(pos.fw > -1 && pos.fh > -1)
27729 highlight_frag(screen, color, pos, 1);
27730 else highlight_sqr(screen, color, pos, 1);
27731 }
27732 }
27733
27734 void textbox_out(BITMAP* dest, FONT* font, int x, int y, int fg, int bg, char const* str, int align, size_and_pos* dims)
27735 {
27736 static size_and_pos nilsz;
27737 size_and_pos& txbox = dims ? *dims : nilsz;
27738
27739 char* kill = (char*)malloc(strlen(str)+1);
27740 char *tmpstr = kill;
27741 strcpy(tmpstr,str);
27742
27743 while(tmpstr[0] == '\n')
27744 ++tmpstr;
27745 int len = strlen(tmpstr);
27746 while(tmpstr[len-1] == '\n')
27747 tmpstr[--len] = 0;
27748
27749 txbox.x=x;
27750 txbox.y=y;
27751 int32_t lines=count_lines(tmpstr);
27752 txbox.w = 1;
27753 txbox.h = lines;
27754 txbox.xscale = get_longest_line_length(font, tmpstr);
27755 txbox.yscale = text_height(font);
27756
27757 int ax = 0; //Aligned x
27758 switch(align)
27759 {
27760 case 0: //left
27761 break;
27762 case 1: //center
27763 txbox.x -= txbox.xscale/2;
27764 ax = txbox.xscale/2;
27765 break;
27766 case 2: //right
27767 txbox.x -= txbox.xscale;
27768 ax = txbox.xscale;
27769 break;
27770 }
27771
27772 int bw = txbox.w*txbox.xscale;
27773 int bh = txbox.h*txbox.yscale;
27774 BITMAP* outbmp = create_bitmap_ex(8, bw, bh);
27775 clear_to_color(outbmp, bg);
27776
27777 char temp = 0;
27778 int32_t t=0;
27779 int32_t new_t=-1;
27780 int32_t line=0;
27781
27782 while(tmpstr[t])
27783 {
27784 t=strchrnum(tmpstr, '\n');
27785
27786 if(t==-1)
27787 t=(int32_t)strlen(tmpstr);
27788
27789 if((uint32_t)t!=strlen(tmpstr))
27790 new_t=t+1;
27791 else
27792 new_t=-1;
27793
27794 temp = tmpstr[t];
27795 tmpstr[t]=0;
27796 gui_textout_ln(outbmp, font, (ucc*)tmpstr, ax, (line*txbox.yscale), fg, -1, align);
27797 tmpstr[t]=temp;
27798 ++line;
27799
27800 if(new_t!=-1)
27801 {
27802 tmpstr+=new_t;
27803 t=0;
27804 }
27805 }
27806
27807 blit(outbmp, dest, 0, 0, txbox.x, txbox.y, bw, bh);
27808 destroy_bitmap(outbmp);
27809 free(kill);
27810 }
27811
27812 void highlight_sqr(BITMAP* dest, int color, int x, int y, int w, int h, int thick)
27813 {
27814 for(int q = 0; q < thick; ++q)
27815 {
27816 safe_rect(dest, x+q, y+q, x+w-1-q, y+h-1-q, color);
27817 }
27818 }
27819 void highlight_sqr(BITMAP* dest, int color, size_and_pos const& rec, int thick)
27820 {
27821 highlight_sqr(dest, color, rec.x, rec.y, rec.tw(), rec.th(), thick);
27822 }
27823 void highlight_frag(BITMAP* dest, int color, int x1, int y1, int w, int h, int fw, int fh, int thick)
27824 {
27825 int xc = x1+fw-1;
27826 int yc = y1+fh-1;
27827 int x2 = x1+w-1;
27828 int y2 = y1+h-1;
27829
27830 hline(dest, x1, y1, x2, color);
27831 vline(dest, x1, y1, y2, color);
27832
27833 hline(dest, x1, y2, xc, color);
27834 vline(dest, x2, y1, yc, color);
27835 hline(dest, xc, yc, x2, color);
27836 vline(dest, xc, yc, y2, color);
27837 }
27838 void highlight_frag(BITMAP* dest, int color, size_and_pos const& rec, int thick)
27839 {
27840 highlight_frag(dest, color, rec.x, rec.y, rec.tw(), rec.th(), rec.fw, rec.fh, thick);
27841 }
27842
27843 void highlight(BITMAP* dest, size_and_pos& hl)
27844 {
27845 if(hl.fw > -1 && hl.fh > -1)
27846 {
27847 highlight_frag(dest, hl.data[1], hl, hl.data[0]);
27848 }
27849 else highlight_sqr(dest, hl.data[1], hl, hl.data[0]);
27850 }
27851
27852 std::pair<int, int> get_box_text_size(char const* tipmsg, double txscale)
27853 {
27854 if(txscale < 1) txscale = 1;
27855 char* kill = (char*)malloc(strlen(tipmsg)+1);
27856 char *tmpstr = kill;
27857 strcpy(tmpstr,tipmsg);
27858
27859 while(tmpstr[0] == '\n')
27860 ++tmpstr;
27861 int len = strlen(tmpstr);
27862 while(tmpstr[len-1] == '\n')
27863 tmpstr[--len] = 0;
27864
27865 int32_t lines = count_lines(tmpstr);
27866 int txlen = get_longest_line_length(font, tmpstr);
27867 int txhei = lines*text_height(font);
27868 int tx_sclen = (txlen * txscale);
27869 int tx_schei = (txhei * txscale);
27870 int w = tx_sclen + 8 + 1;
27871 int h = tx_schei + 8 + 1;
27872 if (w > zq_screen_w)
27873 w = zq_screen_w;
27874 if (h > zq_screen_h)
27875 h = zq_screen_h;
27876 return {w, h};
27877 }
27878
27879 void draw_box(BITMAP* destbmp, size_and_pos* pos, char const* tipmsg, double txscale)
27880 {
27881 if(txscale < 1) txscale = 1;
27882 char* kill = (char*)malloc(strlen(tipmsg)+1);
27883 char *tmpstr = kill;
27884 strcpy(tmpstr,tipmsg);
27885
27886 while(tmpstr[0] == '\n')
27887 ++tmpstr;
27888 int len = strlen(tmpstr);
27889 while(tmpstr[len-1] == '\n')
27890 tmpstr[--len] = 0;
27891
27892 auto& box = *pos;
27893 clear_bitmap(destbmp);
27894
27895 int32_t lines=count_lines(tmpstr);
27896 int txlen = get_longest_line_length(font, tmpstr);
27897 int txhei = lines*text_height(font);
27898 int tx_sclen = (txlen * txscale);
27899 int tx_schei = (txhei * txscale);
27900 box.w = tx_sclen + 8 + 1;
27901 box.h = tx_schei + 8 + 1;
27902 if (box.w > zq_screen_w)
27903 box.w = zq_screen_w;
27904 if (box.h > zq_screen_h)
27905 box.h = zq_screen_h;
27906
27907 if(box.x+box.w>=zq_screen_w)
27908 {
27909 box.x=(zq_screen_w - box.w);
27910 }
27911
27912 if(box.y+box.h>=zq_screen_h)
27913 {
27914 box.y=(zq_screen_h - box.h);
27915 }
27916
27917 rectfill(destbmp, 1, 1, box.w-3, box.h-3, jwin_pal[jcTEXTBG]);
27918 rect(destbmp, 0, 0, box.w-2, box.h-2, jwin_pal[jcTEXTFG]);
27919 vline(destbmp, box.w-1, 0, box.h-1, jwin_pal[jcTEXTFG]);
27920 hline(destbmp, 1, box.h-1, box.w-2, jwin_pal[jcTEXTFG]);
27921 destbmp->line[box.h-1][0]=0;
27922 destbmp->line[0][box.w-1]=0;
27923
27924 char temp = 0;
27925 int32_t t=0;
27926 int32_t new_t=-1;
27927 int32_t line=0;
27928
27929 BITMAP* txbmp = create_bitmap_ex(8,box.w,box.h);
27930 clear_bitmap(txbmp);
27931 while(tmpstr[t])
27932 {
27933 t=strchrnum(tmpstr, '\n');
27934
27935 if(t==-1)
27936 {
27937 t=(int32_t)strlen(tmpstr);
27938 }
27939
27940 if((uint32_t)t!=strlen(tmpstr))
27941 {
27942 new_t=t+1;
27943 }
27944 else
27945 {
27946 new_t=-1;
27947 }
27948
27949 temp = tmpstr[t];
27950 tmpstr[t]=0;
27951 textprintf_ex(txbmp, font, 0, (line*text_height(font)), jwin_pal[jcTEXTFG], -1, "%s", tmpstr);
27952 tmpstr[t]=temp;
27953 ++line;
27954
27955 if(new_t!=-1)
27956 {
27957 tmpstr+=new_t;
27958 t=0;
27959 }
27960 }
27961 masked_stretch_blit(txbmp,destbmp,0,0,txlen,txhei,4,4,tx_sclen,tx_schei);
27962 destroy_bitmap(txbmp);
27963 free(kill);
27964 }
27965
27966 void update_tooltip(int32_t x, int32_t y, size_and_pos const& sqr, char const* tipmsg, double scale)
27967 {
27968 update_tooltip(x,y,sqr.x,sqr.y,sqr.w*sqr.xscale,sqr.h*sqr.yscale,tipmsg,sqr.fw,sqr.fh,scale);
27969 }
27970 void update_tooltip(int32_t x, int32_t y, int32_t tx, int32_t ty, int32_t tw, int32_t th, char const* tipmsg, int fw, int fh, double scale)
27971 {
27972 if(!EnableTooltips)
27973 {
27974 return;
27975 }
27976
27977 ttip_install(ttip_global_id, tipmsg, tx, ty, tw, th, x, y, fw, fh);
27978 }
27979
27980 void ZQ_ClearQuestPath()
27981 {
27982 zc_set_config("zquest","win_last_quest",(char const*)nullptr);
27983 strcpy(filepath,"");
27984 }
27985
27986 //FFCore
27987
27988 int32_t FFScript::GetScriptObjectUID(int32_t type)
27989 {
27990 ++script_UIDs[type];
27991 return script_UIDs[type];
27992 }
27993
27994 void FFScript::init()
27995 {
27996 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
27997 numscriptdraws = 0;
27998 max_ff_rules = qr_MAX;
27999 temp_no_stepforward = 0;
28000 nostepforward = 0;
28001
28002 coreflags = 0;
28003 skip_ending_credits = 0;
28004 music_update_cond = 0;
28005 music_update_flags = 0;
28006 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
28007
28008 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
28009 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
28010 int32_t usr_midi_volume = usr_digi_volume = usr_sfx_volume = usr_music_volume = usr_panstyle = 0;
28011 FF_hero_action = 0;
28012 enemy_removal_point[spriteremovalY1] = -32767;
28013 enemy_removal_point[spriteremovalY2] = 32767;
28014 enemy_removal_point[spriteremovalX1] = -32767;
28015 enemy_removal_point[spriteremovalX2] = 32767;
28016 enemy_removal_point[spriteremovalZ1] = -32767;
28017 enemy_removal_point[spriteremovalZ2] = 32767;
28018
28019 for ( int32_t q = 0; q < 4; q++ )
28020 {
28021 FF_screenbounds[q] = 0;
28022 FF_screen_dimensions[q] = 0;
28023 FF_subscreen_dimensions[q] = 0;
28024 FF_eweapon_removal_bounds[q] = 0;
28025 FF_lweapon_removal_bounds[q] = 0;
28026 }
28027 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
28028 {
28029 FF_clocks[q] = 0;
28030 }
28031 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
28032 {
28033 ScriptDrawingRules[q] = 0;
28034 }
28035 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
28036 {
28037 FF_UserMidis[q] = 0;
28038 }
28039 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
28040 kb_typing_mode = false;
28041 initIncludePaths();
28042 for(int32_t q = 0; q < 7; ++q)
28043 {
28044 tempScreens[q] = NULL;
28045 ScrollingScreens[q] = NULL;
28046 }
28047 }
28048
28049 void FFScript::updateIncludePaths()
28050 {
28051 includePaths.clear();
28052 int32_t pos = 0; int32_t pathnumber = 0;
28053 for ( int32_t q = 0; includePathString[pos]; ++q )
28054 {
28055 int32_t dest = 0;
28056 char buf[2048] = {0};
28057 while(includePathString[pos] != ';' && includePathString[pos])
28058 {
28059 buf[dest] = includePathString[pos];
28060 ++pos;
28061 ++dest;
28062 }
28063 ++pos;
28064 string str(buf);
28065 includePaths.push_back(str);
28066 }
28067 }
28068
28069 void FFScript::initIncludePaths()
28070 {
28071 memset(includePathString,0,sizeof(includePathString));
28072 FILE* f = fopen("includepaths.txt", "r");
28073 if(f)
28074 {
28075 int32_t pos = 0;
28076 int32_t c;
28077 do
28078 {
28079 c = fgetc(f);
28080 if(c!=EOF)
28081 includePathString[pos++] = c;
28082 }
28083 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
28084 if(pos<MAX_INCLUDE_PATH_CHARS)
28085 includePathString[pos] = '\0';
28086 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
28087 fclose(f);
28088 }
28089 else strcpy(includePathString, "include/;headers/;scripts/;");
28090 al_trace("Full path string is: ");
28091 safe_al_trace(includePathString);
28092 al_trace("\n");
28093 updateIncludePaths();
28094
28095 for ( size_t q = 0; q < includePaths.size(); ++q )
28096 {
28097 al_trace("Include path %zu: ",q);
28098 safe_al_trace(includePaths.at(q).c_str());
28099 al_trace("\n");
28100 }
28101 }
28102
28103 int32_t FFScript::getQRBit(int32_t rule)
28104 {
28105 return ( get_qr(rule) ? 1 : 0 );
28106 }
28107
28108 int32_t FFScript::getTime(int32_t type)
28109 {
28110 //struct tm *tm_struct = localtime(time(NULL));
28111 struct tm * tm_struct;
28112 time_t rawtime;
28113 time (&rawtime);
28114 tm_struct = localtime (&rawtime);
28115
28116 switch(type)
28117 {
28118 case curyear:
28119 {
28120 int32_t year = tm_struct->tm_year + 1900; /* year */
28121 //year format starts at 1900, so we add it to the return
28122 return year;
28123
28124 }
28125 case curmonth:
28126 {
28127 int32_t month = tm_struct->tm_mon +1; /* month */
28128 //Months start at 0, but we want 1->12
28129 return month;
28130 }
28131 case curday_month:
28132 {
28133 int32_t day_month = tm_struct->tm_mday; /* day of the month */
28134 return day_month;
28135 }
28136 case curday_week:
28137 {
28138 int32_t day_week = tm_struct->tm_wday; /* day of the week */
28139 return day_week;
28140 }
28141 case curhour:
28142 {
28143 int32_t hour = tm_struct->tm_hour; /* hours */
28144 return hour;
28145 }
28146 case curminute:
28147 {
28148 int32_t minutes = tm_struct->tm_min; /* minutes */
28149 return minutes;
28150 }
28151 case cursecond:
28152 {
28153 int32_t secs = tm_struct->tm_sec; /* seconds */
28154 return secs;
28155 }
28156 case curdayyear:
28157 {
28158 int32_t day_year = tm_struct->tm_yday; /* day in the year */
28159 return day_year;
28160 }
28161 case curDST:
28162 {
28163 int32_t isDST = tm_struct->tm_isdst; /* daylight saving time */
28164 return isDST;
28165 }
28166 default: return -1;
28167
28168 }
28169 }
28170
28171 extern const char *itemclass_help_string_defaults[itype_max];
28172 //ZModule Functions
28173
28174
28175
28176 /* end */
28177
28178 16384 int32_t FFScript::getQuestHeaderInfo(int32_t type)
28179 {
28180 16384 return quest_format[type];
28181 }
28182
28183 bool isSideViewGravity(int32_t t)
28184 {
28185 return (Map.CurrScr()->flags7&fSIDEVIEW) != 0;
28186 }
28187
28188
28189
28190
28191 void FFScript::ZScriptConsole(bool open)
28192 {
28193
28194
28195 #ifdef _WIN32
28196 if ( console_is_open )
28197 {
28198 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
28199 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
28200 zscript_coloured_console.gotoxy(0,0);
28201 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
28202 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
28203 }
28204 else
28205 {
28206 //close
28207 zscript_coloured_console.Close();
28208 }
28209 #endif
28210 }
28211
28212 template <typename ...Params>
28213 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
28214 {
28215 #ifdef _WIN32
28216 initConsole();
28217 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)... );
28218 #endif
28219 }
28220
28221 int32_t getpitfall(int32_t x, int32_t y){return 0;}
28222
28223 int32_t iswaterexzq(int32_t combo, int32_t map, int32_t screen, int32_t layer, int32_t x, int32_t y, bool secrets, bool fullcheck, bool LayerCheck){return 0;}
28224
28225 int32_t MAPCOMBOzq(int32_t x, int32_t y){return 0;}
28226
28227 bool update_hw_pal = false;
28228 void update_hw_screen()
28229 {
28230 if (is_headless())
28231 return;
28232
28233 framecnt++;
28234
28235 zc_process_display_events();
28236 if (update_hw_pal)
28237 {
28238 zc_set_palette(RAMpal);
28239 update_hw_pal = false;
28240 }
28241
28242 render_timer_wait();
28243 render_zq();
28244 }
28245
28246 bool checkCost(int32_t ctr, int32_t amnt)
28247 {
28248 if(!game) return true;
28249 if(amnt <= 0) return true;
28250 switch (ctr)
28251 {
28252 case crMONEY: //rupees
28253 {
28254 if ( current_item_power(itype_wallet) ) return true;
28255 break;
28256 }
28257 case crMAGIC: //magic
28258 {
28259 if (get_qr(qr_ENABLEMAGIC))
28260 {
28261 return (((current_item_power(itype_magicring) > 0)
28262 ? game->get_maxmagic()
28263 : game->get_magic()+game->get_dmagic())>=amnt*game->get_magicdrainrate());
28264 }
28265 return true;
28266 }
28267 case crARROWS:
28268 {
28269 if(current_item_power(itype_quiver))
28270 return true;
28271 if(!get_qr(qr_TRUEARROWS))
28272 return checkCost(crMONEY, amnt);
28273 break;
28274 }
28275 case crBOMBS:
28276 {
28277 if(current_item_power(itype_bombbag))
28278 return true;
28279 break;
28280 }
28281 case crSBOMBS:
28282 {
28283 if(current_item_power(itype_bombbag)
28284 && itemsbuf[current_item_id(itype_bombbag)].flags & item_flag1)
28285 return true;
28286 break;
28287 }
28288 }
28289 return (game->get_counter(ctr)+game->get_dcounter(ctr)>=amnt);
28290 }
28291 bool checkmagiccost(int32_t itemid, bool checkTime)
28292 {
28293 if(itemid < 0)
28294 {
28295 return false;
28296 }
28297 itemdata const& id = itemsbuf[itemid];
28298 return checkCost(id.cost_counter[0], id.cost_amount[0])
28299 && checkCost(id.cost_counter[1], id.cost_amount[1]);
28300 }
28301
28302 void payCost(int32_t ctr, int32_t amnt, int32_t tmr, bool ignoreTimer)
28303 {
28304 return;
28305 }
28306 void paymagiccost(int32_t itemid, bool ignoreTimer, bool onlyTimer)
28307 {
28308 return;
28309 }
28310
28311 void enter_sys_pal(){}
28312 void exit_sys_pal(){}
28313
28314 void replay_step_comment(std::string comment) {}
28315 bool replay_is_active() {return false;}
28316 bool replay_is_replaying() {return false;}
28317 bool replay_version_check(int min, int max) {return false;}
28318 bool replay_is_debug() {return false;}
28319 int32_t item::run_script(int32_t mode){return 0;};
28320
28321 #ifdef __EMSCRIPTEN__
28322 extern "C" void open_test_mode()
28323 {
28324 int dmap = -1;
28325 int32_t pal = Map.getcolor();
28326 for(auto q = 0; q < MAXDMAPS; ++q)
28327 {
28328 if(DMaps[q].map == Map.getCurrMap())
28329 {
28330 if(pal == DMaps[q].color)
28331 {
28332 dmap = q;
28333 break;
28334 }
28335 if(dmap < 0)
28336 dmap = q;
28337 }
28338 }
28339 if(dmap < 0) dmap = 0;
28340
28341 em_open_test_mode(filepath, dmap, Map.getCurrScr(), -1);
28342 }
28343
28344 extern "C" void get_shareable_url()
28345 {
28346 EM_ASM({
28347 ZC.setShareableUrl({open: UTF8ToString($0), map: $1, screen: $2});
28348 }, filepath, Map.getCurrMap(), Map.getCurrScr());
28349 }
28350 #endif
28351